diff options
| author | Seba Gamboa <[email protected]> | 2015-10-14 14:37:47 -0300 |
|---|---|---|
| committer | Seba Gamboa <[email protected]> | 2015-10-20 12:16:47 -0300 |
| commit | 5cdcce8dbddd94ecb9503a0a1d47370c4ef97177 (patch) | |
| tree | 07dae36bc4e2762a8d420fbea2e67b4a087ea260 /mrbgems/mruby-hash-ext | |
| parent | 84b70886cd9827593810264bf1f068044d5c6986 (diff) | |
| download | mruby-5cdcce8dbddd94ecb9503a0a1d47370c4ef97177.tar.gz mruby-5cdcce8dbddd94ecb9503a0a1d47370c4ef97177.zip | |
Mark core gems with mrbgem tag
Diffstat (limited to 'mrbgems/mruby-hash-ext')
| -rw-r--r-- | mrbgems/mruby-hash-ext/mrblib/hash.rb | 19 | ||||
| -rw-r--r-- | mrbgems/mruby-hash-ext/src/hash-ext.c | 2 |
2 files changed, 13 insertions, 8 deletions
diff --git a/mrbgems/mruby-hash-ext/mrblib/hash.rb b/mrbgems/mruby-hash-ext/mrblib/hash.rb index ec8bd05fb..28ffd8146 100644 --- a/mrbgems/mruby-hash-ext/mrblib/hash.rb +++ b/mrbgems/mruby-hash-ext/mrblib/hash.rb @@ -1,6 +1,8 @@ class Hash # ISO does not define Hash#each_pair, so each_pair is defined in gem. + # + # @mrbgem mruby-hash-ext alias each_pair each ## @@ -22,7 +24,7 @@ class Hash # Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200} # Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200} # - + # @mrbgem mruby-hash-ext def self.[](*object) length = object.length if length == 1 @@ -80,7 +82,7 @@ class Hash # h1.merge!(h2) { |key, v1, v2| v1 } # #=> {"a"=>100, "b"=>200, "c"=>300} # - + # @mrbgem mruby-hash-ext def merge!(other, &block) raise TypeError, "can't convert argument into Hash" unless other.respond_to?(:to_hash) if block @@ -122,7 +124,7 @@ class Hash # prog.rb:2:in 'fetch': key not found (KeyError) # from prog.rb:2 # - + # @mrbgem mruby-hash-ext def fetch(key, none=NONE, &block) unless self.key?(key) if block @@ -150,7 +152,7 @@ class Hash # h = { "a" => 100, "b" => 200, "c" => 300 } # h.delete_if {|key, value| key >= "b" } #=> {"a"=>100} # - + # @mrbgem mruby-hash-ext def delete_if(&block) return to_enum :delete_if unless block_given? @@ -175,7 +177,7 @@ class Hash # a.flatten # => [1, "one", 2, [2, "two"], 3, "three"] # a.flatten(2) # => [1, "one", 2, 2, "two", 3, "three"] # - + # @mrbgem mruby-hash-ext def flatten(level=1) self.to_a.flatten(level) end @@ -190,7 +192,7 @@ class Hash # h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 } # h.invert #=> {0=>"a", 100=>"m", 200=>"d", 300=>"y"} # - + # @mrbgem mruby-hash-ext def invert h = Hash.new self.each {|k, v| h[v] = k } @@ -207,7 +209,7 @@ class Hash # # If no block is given, an enumerator is returned instead. # - + # @mrbgem mruby-hash-ext def keep_if(&block) return to_enum :keep_if unless block_given? @@ -232,7 +234,7 @@ class Hash # h.key(300) #=> "c" # h.key(999) #=> nil # - + # @mrbgem mruby-hash-ext def key(val) self.each do |k, v| return k if v == val @@ -247,6 +249,7 @@ class Hash # Returns +self+. If called on a subclass of Hash, converts # the receiver to a Hash object. # + # @mrbgem mruby-hash-ext def to_h self end diff --git a/mrbgems/mruby-hash-ext/src/hash-ext.c b/mrbgems/mruby-hash-ext/src/hash-ext.c index bce842cb4..d9a3b8de0 100644 --- a/mrbgems/mruby-hash-ext/src/hash-ext.c +++ b/mrbgems/mruby-hash-ext/src/hash-ext.c @@ -17,6 +17,8 @@ * * h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" } * h.values_at("cow", "cat") #=> ["bovine", "feline"] + * + * @mrbgem mruby-hash-ext */ static mrb_value |
