Commit 91da1824 authored by Daniel Bovensiepen's avatar Daniel Bovensiepen

Add documentation for Struct

parent 2c48bf45
##
# Struct
#
# Struct
#
# ISO 15.2.18
class Struct
# 15.2.18.4.4
##
# Calls the given block for each element of +self+
# and pass the respective element.
#
# ISO 15.2.18.4.4
def each(&block)
self.class.members.each{|field|
block.call(self[field])
......@@ -10,7 +16,12 @@ class Struct
self
end
# 15.2.18.4.5
##
# Calls the given block for each element of +self+
# and pass the name and value of the respectiev
# element.
#
# ISO 15.2.18.4.5
def each_pair(&block)
self.class.members.each{|field|
block.call(field.to_sym, self[field])
......@@ -18,7 +29,12 @@ class Struct
self
end
# 15.2.18.4.7
##
# Calls the given block for each element of +self+
# and returns an array with all elements of which
# block is not false.
#
# ISO 15.2.18.4.7
def select(&block)
ary = []
self.class.members.each{|field|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment