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.
664 665 666 667 |
# File 'lib/sup/util.rb', line 664 def initialize *a @keys = [] a.each { |k, v| self[k] = v } end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
662 663 664 |
# File 'lib/sup/util.rb', line 662 def keys @keys end |
Instance Method Details
#[]=(key, val) ⇒ Object
669 670 671 672 |
# File 'lib/sup/util.rb', line 669 def []= key, val @keys << key unless member?(key) super end |
#delete(key) ⇒ Object
677 678 679 680 |
# File 'lib/sup/util.rb', line 677 def delete key @keys.delete key super end |
#each ⇒ Object
682 |
# File 'lib/sup/util.rb', line 682 def each; @keys.each { |k| yield k, self[k] } end |
#each_pair ⇒ Object
661 |
# File 'lib/sup/util.rb', line 661 alias_method :each_pair, :each |
#index(key) ⇒ Object
675 |
# File 'lib/sup/util.rb', line 675 def index key; @keys.index key end |
#store ⇒ Object
660 |
# File 'lib/sup/util.rb', line 660 alias_method :store, :[]= |
#values ⇒ Object
674 |
# File 'lib/sup/util.rb', line 674 def values; keys.map { |k| self[k] } end |