summaryrefslogtreecommitdiffhomepage
path: root/mrblib/struct.rb
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-05-03 08:21:56 +0900
committerYukihiro Matsumoto <[email protected]>2012-05-03 08:21:56 +0900
commit7e4c545760c78b3870361820cccd7dbc0b849c46 (patch)
treedaff7d63f20c0598cf0c8875a772ce47916afe9e /mrblib/struct.rb
parent0c6bd79d8a731e7371bd052160599fa79c321dd7 (diff)
parentda9fa2346a9a851bdc98946a3502ea0c3c676207 (diff)
downloadmruby-7e4c545760c78b3870361820cccd7dbc0b849c46.tar.gz
mruby-7e4c545760c78b3870361820cccd7dbc0b849c46.zip
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'mrblib/struct.rb')
-rw-r--r--mrblib/struct.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/mrblib/struct.rb b/mrblib/struct.rb
index b11f59f2a..4b6d767a9 100644
--- a/mrblib/struct.rb
+++ b/mrblib/struct.rb
@@ -1,8 +1,14 @@
+##
+# 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|