Class: Ebayr::Record
- Inherits:
-
Hash
- Object
- Hash
- Ebayr::Record
- Defined in:
- lib/ebayr/record.rb
Direct Known Subclasses
Instance Method Summary collapse
- #<=>(another) ⇒ Object
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize(initial = {}) ⇒ Record
constructor
A new instance of Record.
Constructor Details
#initialize(initial = {}) ⇒ Record
Returns a new instance of Record.
4 5 6 7 |
# File 'lib/ebayr/record.rb', line 4 def initialize(initial = {}) super() initial.each { |k, v| self[k] = v } end |
Instance Method Details
#<=>(another) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/ebayr/record.rb', line 9 def <=>(another) return false unless another.respond_to(:keys) and another.respond_to(:"[]") another.keys.each do |k| return false unless convert_value(another[k]) == self[k] end true end |
#[](key) ⇒ Object
17 18 19 |
# File 'lib/ebayr/record.rb', line 17 def [](key) super(convert_key(key)) end |
#[]=(key, value) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ebayr/record.rb', line 21 def []=(key, value) key = convert_key(key) value = convert_value(value) (class << self; self; end).send(:define_method, key) { value } super(key, value) end |
#has_key?(key) ⇒ Boolean
28 29 30 |
# File 'lib/ebayr/record.rb', line 28 def has_key?(key) super(convert_key(key)) end |