Class: OrderedHash
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
Instance Method Summary collapse
- #[]=(key, val) ⇒ Object
- #delete(key) ⇒ Object
- #each ⇒ Object
- #each_pair ⇒ Object
- #index(key) ⇒ Object
-
#initialize(*a) ⇒ OrderedHash
constructor
A new instance of OrderedHash.
- #store ⇒ Object
- #values ⇒ Object
Methods inherited from Hash
Constructor Details
#initialize(*a) ⇒ OrderedHash
Returns a new instance of OrderedHash.
628 629 630 631 |
# File 'lib/sup/util.rb', line 628 def initialize *a @keys = [] a.each { |k, v| self[k] = v } end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
626 627 628 |
# File 'lib/sup/util.rb', line 626 def keys @keys end |
Instance Method Details
#[]=(key, val) ⇒ Object
633 634 635 636 |
# File 'lib/sup/util.rb', line 633 def []= key, val @keys << key unless member?(key) super end |
#delete(key) ⇒ Object
641 642 643 644 |
# File 'lib/sup/util.rb', line 641 def delete key @keys.delete key super end |
#each ⇒ Object
646 |
# File 'lib/sup/util.rb', line 646 def each; @keys.each { |k| yield k, self[k] } end |
#each_pair ⇒ Object
625 |
# File 'lib/sup/util.rb', line 625 alias_method :each_pair, :each |
#index(key) ⇒ Object
639 |
# File 'lib/sup/util.rb', line 639 def index key; @keys.index key end |
#store ⇒ Object
624 |
# File 'lib/sup/util.rb', line 624 alias_method :store, :[]= |
#values ⇒ Object
638 |
# File 'lib/sup/util.rb', line 638 def values; keys.map { |k| self[k] } end |