Class: Kwalify::Util::OrderedHash
- Inherits:
-
Hash
- Object
- Hash
- Kwalify::Util::OrderedHash
show all
- Defined in:
- lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb
Instance Method Summary
collapse
Methods included from HashUtils
#recursively, #rekey, #stringify_keys, #symbolize_keys
#with_indifferent_access
Constructor Details
#initialize(*args, &block) ⇒ OrderedHash
Returns a new instance of OrderedHash.
13
14
15
16
|
# File 'lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb', line 13
def initialize(*args, &block)
super
@_keys = []
end
|
Instance Method Details
#add(key, val) ⇒ Object
25
26
27
28
29
|
# File 'lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb', line 25
def add(key, val)
@_keys.delete_at(@_keys.index(key)) if self.key?(key)
@_keys << key
__set__(key, val)
end
|
#delete(key) ⇒ Object
42
43
44
45
|
# File 'lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb', line 42
def delete(key)
@_keys.delete_at(@_keys.index(key)) if self.key?(key)
super
end
|
#each ⇒ Object
47
48
49
50
51
|
# File 'lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb', line 47
def each
@_keys.each do |key|
yield key, self[key]
end
end
|
#keys ⇒ Object
34
35
36
|
# File 'lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb', line 34
def keys
return @_keys.dup
end
|
#put(key, val) ⇒ Object
Also known as:
[]=
20
21
22
23
|
# File 'lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb', line 20
def put(key, val)
@_keys << key unless self.key?(key)
__set__(key, val)
end
|
#values ⇒ Object
38
39
40
|
# File 'lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb', line 38
def values
return @_keys.collect {|key| self[key] }
end
|