From b584bb715b3f68a4b356fcce549e5f29342e6ff0 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 6 May 2012 18:15:02 +0800 Subject: Modify documentation of Array --- mrblib/array.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mrblib/array.rb b/mrblib/array.rb index 905b41cb0..881f22df7 100644 --- a/mrblib/array.rb +++ b/mrblib/array.rb @@ -88,10 +88,12 @@ class Array end end -# include modules +## +# Array is enumerable and comparable module Enumerable; end module Comparable; end class Array + # ISO 15.2.12.3 include Enumerable include Comparable -- cgit v1.2.3 From 8f4c1af9e4ca995d891c1f1b52113e90fe213ba5 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 6 May 2012 18:15:23 +0800 Subject: Add documentation to Hash --- mrblib/hash.rb | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/mrblib/hash.rb b/mrblib/hash.rb index 7157684f8..b32c30b83 100644 --- a/mrblib/hash.rb +++ b/mrblib/hash.rb @@ -1,8 +1,17 @@ +## +# Hash # -# Hash -# +# ISO 15.2.13 class Hash - # 15.2.13.4.8 + + ## + # Delete the element with the key +key+. + # Return the value of the element if +key+ + # was found. Return nil if nothing was + # found. If a block is given, call the + # block with the value of the element. + # + # ISO 15.2.13.4.8 def delete(key, &block) if block && ! self.has_key?(key) block.call(key) @@ -11,29 +20,53 @@ class Hash end end - # 15.2.13.4.9 + ## + # Calls the given block for each element of +self+ + # and pass the key and value of each element. + # + # ISO 15.2.13.4.9 def each(&block) self.keys.each{|k| block.call([k, self[k]])} self end - # 15.2.13.4.10 + ## + # Calls the given block for each element of +self+ + # and pass the key of each element. + # + # ISO 15.2.13.4.10 def each_key(&block) self.keys.each{|k| block.call(k)} self end - # 15.2.13.4.11 + ## + # Calls the given block for each element of +self+ + # and pass the value of each element. + # + # ISO 15.2.13.4.11 def each_value(&block) self.keys.each{|k| block.call(self[k])} self end - # 15.2.13.4.16 + ## + # Create a direct instance of the class Hash. + # + # ISO 15.2.13.4.16 def initialize(*args, &block) self.__init_core(block, *args) end + ## + # Return a hash which contains the content of + # +self+ and +other+. If a block is given + # call the block for each duplicate key and + # pass the key, old value and new value. + # The value of the block will be replacing + # the duplicate element in the has which will + # be returned. + # # 15.2.13.4.22 def merge(other, &block) h = {} @@ -51,7 +84,10 @@ class Hash end end -# include modules +## +# Hash is enumerable +# +# ISO 15.2.13.3 module Enumerable; end class Hash include Enumerable -- cgit v1.2.3 From 55f143d4e39545e5a8520f51679364606b2fbef0 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 6 May 2012 18:15:38 +0800 Subject: Add documentation to Kernel --- mrblib/kernel.rb | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/mrblib/kernel.rb b/mrblib/kernel.rb index c09755d6c..fd4c86c38 100644 --- a/mrblib/kernel.rb +++ b/mrblib/kernel.rb @@ -1,21 +1,33 @@ +## +# Kernel # -# Kernel -# +# ISO 15.3.1 module Kernel - # 15.3.1.2.6 + + ## + # Takes the given block, create a lambda + # out of it and +call+ it. + # + # ISO 15.3.1.2.6 def self.lambda(&block) ### *** TODO *** ### block # dummy end - # 15.3.1.2.8 + ## + # Calls the given block repetitively. + # + # ISO 15.3.1.2.8 def self.loop #(&block) while(true) yield end end - # 15.3.1.3.4 + ## + # Alias for +send+. + # + # ISO 15.3.1.3.4 def __send__(symbol, *args, &block) ### *** TODO *** ### end @@ -25,20 +37,31 @@ module Kernel ### *** TODO *** ### end + ## + # Alias for Kernel.lambda. + # # 15.3.1.3.27 def lambda(&block) ### *** TODO *** ### block # dummy end - # 15.3.1.3.29 + ## + # Alias for Kernel.loop. + # + # ISO 15.3.1.3.29 def loop #(&block) while(true) yield end end - # 15.3.1.3.44 + ## + # Invoke the method with the name +symbol+ on + # the receiver and pass +args+ and the given + # block. + # + # ISO 15.3.1.3.44 def send(symbol, *args, &block) ### *** TODO *** ### end -- cgit v1.2.3 From b032acd6b6839b3c819868248b62c14386335591 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 6 May 2012 18:16:02 +0800 Subject: Modify documentation of Numeric --- mrblib/numeric.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mrblib/numeric.rb b/mrblib/numeric.rb index 08600b0bf..9f65d5633 100644 --- a/mrblib/numeric.rb +++ b/mrblib/numeric.rb @@ -48,7 +48,10 @@ class Integer end end -# include modules +## +# Numeric is comparable +# +# ISO 15.2.7.3 module Comparable; end class Numeric include Comparable -- cgit v1.2.3 From dea4ccdd97b4ccb3a875e5b96036e03e5a25c1ae Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 6 May 2012 18:16:26 +0800 Subject: Add documentation to Range --- mrblib/range.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mrblib/range.rb b/mrblib/range.rb index 79bc40ecd..8f43f3cbb 100644 --- a/mrblib/range.rb +++ b/mrblib/range.rb @@ -1,8 +1,14 @@ +## +# Range # -# Range -# +# ISO 15.2.14 class Range - # 15.2.14.4.4 + + ## + # Calls the given block for each element of +self+ + # and pass the respective element. + # + # ISO 15.2.14.4.4 def each(&block) val = self.first unless val.respond_to? :succ @@ -23,7 +29,10 @@ class Range end end -# include modules +## +# Range is enumerable +# +# ISO module Enumerable; end class Range include Enumerable -- cgit v1.2.3 From 580b0267a8590fc426f0ad9b77ab7b3f4448de24 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 6 May 2012 18:24:39 +0800 Subject: Some fixes for the Documentation of Hash and Kernel --- mrblib/hash.rb | 12 +++++------- mrblib/kernel.rb | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/mrblib/hash.rb b/mrblib/hash.rb index b32c30b83..d6ad55e47 100644 --- a/mrblib/hash.rb +++ b/mrblib/hash.rb @@ -61,13 +61,11 @@ class Hash ## # Return a hash which contains the content of # +self+ and +other+. If a block is given - # call the block for each duplicate key and - # pass the key, old value and new value. - # The value of the block will be replacing - # the duplicate element in the has which will - # be returned. - # - # 15.2.13.4.22 + # it will be called for each element with + # a duplicate key. The value of the block + # will be the final value of this element. + # + # ISO 15.2.13.4.22 def merge(other, &block) h = {} raise "can't convert argument into Hash" unless other.respond_to?(:to_hash) diff --git a/mrblib/kernel.rb b/mrblib/kernel.rb index fd4c86c38..2e017f818 100644 --- a/mrblib/kernel.rb +++ b/mrblib/kernel.rb @@ -38,7 +38,7 @@ module Kernel end ## - # Alias for Kernel.lambda. + # Alias for +Kernel.lambda+. # # 15.3.1.3.27 def lambda(&block) @@ -47,7 +47,7 @@ module Kernel end ## - # Alias for Kernel.loop. + # Alias for +Kernel.loop+. # # ISO 15.3.1.3.29 def loop #(&block) -- cgit v1.2.3 From 5bab3fc9e09c465cdd6997b87e2aabb6fb159335 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 6 May 2012 18:27:07 +0800 Subject: Forgot ISO Reference Code of Range - Enumerable --- mrblib/range.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrblib/range.rb b/mrblib/range.rb index 8f43f3cbb..44be0305b 100644 --- a/mrblib/range.rb +++ b/mrblib/range.rb @@ -32,7 +32,7 @@ end ## # Range is enumerable # -# ISO +# ISO 15.2.14.3 module Enumerable; end class Range include Enumerable -- cgit v1.2.3 From 1906d6eb33ea7e9643a7f506b83c13bcccf133dd Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 6 May 2012 18:28:52 +0800 Subject: Add ISO mark to Kernel.lambda --- mrblib/kernel.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrblib/kernel.rb b/mrblib/kernel.rb index 2e017f818..f98284d24 100644 --- a/mrblib/kernel.rb +++ b/mrblib/kernel.rb @@ -40,7 +40,7 @@ module Kernel ## # Alias for +Kernel.lambda+. # - # 15.3.1.3.27 + # ISO 15.3.1.3.27 def lambda(&block) ### *** TODO *** ### block # dummy -- cgit v1.2.3