Class: HashEntries
- Inherits:
-
Array
show all
- Defined in:
- ext/enterprise_script_service/mruby/test/t/hash.rb
Constant Summary
Constants included
from Enumerable
Enumerable::NONE
Instance Method Summary
collapse
Methods inherited from Array
#&, #-, #<=>, #==, #_assertion_join, #_inspect, #bsearch, #bsearch_index, #collect!, #combination, #compact, #compact!, #delete, #delete_if, #difference, #dig, #each, #each_index, #eql?, #fetch, #fill, #flatten, #flatten!, #index, #insert, #intersection, #keep_if, #permutation, #reject!, #reverse_each, #rotate, #rotate!, #select!, #sort, #sort!, #to_a, #to_h, #transpose, #union, #uniq, #uniq!, #|
Methods included from Enumerable
#all?, #any?, #chain, #collect, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_slice, #each_with_index, #each_with_object, #entries, #filter_map, #find_all, #find_index, #first, #flat_map, #grep, #group_by, #hash, #include?, #inject, #lazy, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reject, #reverse_each, #sort, #sort_by, #take, #take_while, #tally, #to_h, #uniq, #zip
Constructor Details
#initialize(entries) ⇒ HashEntries
46
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 46
def initialize(entries) self.replace(entries) end
|
Instance Method Details
53
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 53
def dup2; self.class[*map{|k, v| [k.dup, v.dup]}] end
|
#each_key(&block) ⇒ Object
51
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 51
def each_key(&block) each{|k, v| block.(k)} end
|
#each_value(&block) ⇒ Object
52
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 52
def each_value(&block) each{|k, v| block.(v)} end
|
#hash_for(hash = {}, &block) ⇒ Object
57
58
59
60
61
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 57
def hash_for(hash={}, &block)
each{|k, v| hash[k] = v}
block.(hash) if block
hash
end
|
#key(index, k = get=true) ⇒ Object
47
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 47
def key(index, k=get=true) get ? self[index][0] : (self[index][0] = k) end
|
49
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 49
def keys; map{|k, v| k} end
|
#to_s ⇒ Object
Also known as:
inspect
54
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 54
def to_s; "#{self.class}#{super}" end
|
#value(index, v = get=true) ⇒ Object
48
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 48
def value(index, v=get=true) get ? self[index][1] : (self[index][1] = v) end
|
50
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 50
def values; map{|k, v| v} end
|