Class: Aston::Attributes
- Inherits:
-
Object
- Object
- Aston::Attributes
- Defined in:
- lib/aston.rb
Overview
Wrapper for attributes
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(data = {}) ⇒ Attributes
constructor
A new instance of Attributes.
- #size ⇒ Object
- #to_hash ⇒ Object
- #to_json(opts = nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Attributes
Returns a new instance of Attributes.
13 14 15 |
# File 'lib/aston.rb', line 13 def initialize(data = {}) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/aston.rb', line 11 def data @data end |
Instance Method Details
#==(other) ⇒ Object
29 30 31 |
# File 'lib/aston.rb', line 29 def ==(other) other.is_a?(Attributes) && @data == other.data end |
#[](key) ⇒ Object
21 22 23 |
# File 'lib/aston.rb', line 21 def [](key) @data[key] end |
#[]=(key, value) ⇒ Object
25 26 27 |
# File 'lib/aston.rb', line 25 def []=(key, value) @data[key] = value end |
#size ⇒ Object
33 34 35 |
# File 'lib/aston.rb', line 33 def size @data.size end |
#to_hash ⇒ Object
17 18 19 |
# File 'lib/aston.rb', line 17 def to_hash @data end |
#to_json(opts = nil) ⇒ Object
41 42 43 |
# File 'lib/aston.rb', line 41 def to_json(opts = nil) @data.to_json(opts) end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/aston.rb', line 37 def to_s @data.map { |k, v| "#{k}='#{v}'" }.join(' ') end |