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.
704 705 706 707 |
# File 'lib/sup/util.rb', line 704 def initialize *a @keys = [] a.each { |k, v| self[k] = v } end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
702 703 704 |
# File 'lib/sup/util.rb', line 702 def keys @keys end |
Instance Method Details
#[]=(key, val) ⇒ Object
709 710 711 712 |
# File 'lib/sup/util.rb', line 709 def []= key, val @keys << key unless member?(key) super end |
#delete(key) ⇒ Object
717 718 719 720 |
# File 'lib/sup/util.rb', line 717 def delete key @keys.delete key super end |
#each ⇒ Object
722 |
# File 'lib/sup/util.rb', line 722 def each; @keys.each { |k| yield k, self[k] } end |
#each_pair ⇒ Object
701 |
# File 'lib/sup/util.rb', line 701 alias_method :each_pair, :each |
#index(key) ⇒ Object
715 |
# File 'lib/sup/util.rb', line 715 def index key; @keys.index key end |
#store ⇒ Object
700 |
# File 'lib/sup/util.rb', line 700 alias_method :store, :[]= |
#values ⇒ Object
714 |
# File 'lib/sup/util.rb', line 714 def values; keys.map { |k| self[k] } end |