Class: Nanaimo::Object
- Inherits:
-
Object
- Object
- Nanaimo::Object
- Defined in:
- lib/nanaimo/object.rb
Overview
An object that belongs to a plist.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#annotation ⇒ String
The annotation comment.
-
#value ⇒ Object
The underlying native Ruby value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
-
#as_ruby ⇒ Object
A native Ruby object representation.
- #hash ⇒ Object
-
#initialize(value, annotation) ⇒ Object
constructor
A new instance of Object.
- #to_s ⇒ Object
Constructor Details
#initialize(value, annotation) ⇒ Object
Returns a new instance of Object.
15 16 17 18 19 20 |
# File 'lib/nanaimo/object.rb', line 15 def initialize(value, annotation) self.value = value self.annotation = annotation raise 'Item cannot be initialize with a nil value' if value.nil? end |
Instance Attribute Details
#annotation ⇒ String
Returns The annotation comment.
13 14 15 |
# File 'lib/nanaimo/object.rb', line 13 def annotation @annotation end |
#value ⇒ Object
Returns The underlying native Ruby value.
9 10 11 |
# File 'lib/nanaimo/object.rb', line 9 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nanaimo/object.rb', line 36 def <=>(other) other_value = if other.is_a?(Object) other.value elsif other.is_a?(value.class) other end return unless other_value value <=> other_value end |
#==(other) ⇒ Object Also known as: eql?
22 23 24 25 26 27 28 29 |
# File 'lib/nanaimo/object.rb', line 22 def ==(other) return unless other if other.is_a?(self.class) other.value == value && annotation == other.annotation elsif other.is_a?(value.class) other == value end end |
#as_ruby ⇒ Object
Returns A native Ruby object representation.
53 54 55 |
# File 'lib/nanaimo/object.rb', line 53 def as_ruby raise 'unimplemented' end |
#hash ⇒ Object
32 33 34 |
# File 'lib/nanaimo/object.rb', line 32 def hash value.hash end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/nanaimo/object.rb', line 47 def to_s format('<%s %s>', self.class, value) end |