Class: Simmer::Util::Record
- Inherits:
-
Object
- Object
- Simmer::Util::Record
- Extended by:
- Forwardable
- Defined in:
- lib/simmer/util/record.rb
Overview
A less strict comparable hash data structure. It does not depend on key type, value type, and key ordering.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(data = {}) ⇒ Record
constructor
A new instance of Record.
- #keys ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Record
Returns a new instance of Record.
21 22 23 24 25 |
# File 'lib/simmer/util/record.rb', line 21 def initialize(data = {}) data = data.respond_to?(:to_h) ? data.to_h : data @data = sorted_string_hash(data) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
17 18 19 |
# File 'lib/simmer/util/record.rb', line 17 def data @data end |
Instance Method Details
#<=>(other) ⇒ Object
27 28 29 |
# File 'lib/simmer/util/record.rb', line 27 def <=>(other) data <=> other.data end |
#==(other) ⇒ Object Also known as: eql?
31 32 33 |
# File 'lib/simmer/util/record.rb', line 31 def ==(other) other.instance_of?(self.class) && data == other.data end |
#keys ⇒ Object
36 37 38 |
# File 'lib/simmer/util/record.rb', line 36 def keys data.map(&:first) end |