Class: Code::Object::Dictionnary
- Inherits:
-
Code::Object
- Object
- Code::Object
- Code::Object::Dictionnary
- Defined in:
- lib/code/object/dictionnary.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #fetch(key, default = ::Code::Object::Nothing.new) ⇒ Object
- #hash ⇒ Object
-
#initialize(raw = {}) ⇒ Dictionnary
constructor
A new instance of Dictionnary.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(raw = {}) ⇒ Dictionnary
Returns a new instance of Dictionnary.
6 7 8 |
# File 'lib/code/object/dictionnary.rb', line 6 def initialize(raw = {}) @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
4 5 6 |
# File 'lib/code/object/dictionnary.rb', line 4 def raw @raw end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
22 23 24 |
# File 'lib/code/object/dictionnary.rb', line 22 def ==(other) raw == other.raw end |
#fetch(key, default = ::Code::Object::Nothing.new) ⇒ Object
18 19 20 |
# File 'lib/code/object/dictionnary.rb', line 18 def fetch(key, default = ::Code::Object::Nothing.new) raw.fetch(key, default) end |
#hash ⇒ Object
27 28 29 |
# File 'lib/code/object/dictionnary.rb', line 27 def hash [self.class, raw].hash end |
#inspect ⇒ Object
14 15 16 |
# File 'lib/code/object/dictionnary.rb', line 14 def inspect to_s end |
#to_s ⇒ Object
10 11 12 |
# File 'lib/code/object/dictionnary.rb', line 10 def to_s "{#{raw.map { |key, value| "#{key.inspect} => #{value.inspect}" }.join(", ")}}" end |