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.
13 14 15 16 17 18 |
# File 'lib/nanaimo/object.rb', line 13 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.
11 12 13 |
# File 'lib/nanaimo/object.rb', line 11 def annotation @annotation end |
#value ⇒ Object
Returns The underlying native Ruby value.
7 8 9 |
# File 'lib/nanaimo/object.rb', line 7 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/nanaimo/object.rb', line 34 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?
20 21 22 23 24 25 26 27 |
# File 'lib/nanaimo/object.rb', line 20 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.
51 52 53 |
# File 'lib/nanaimo/object.rb', line 51 def as_ruby raise 'unimplemented' end |
#hash ⇒ Object
30 31 32 |
# File 'lib/nanaimo/object.rb', line 30 def hash value.hash end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/nanaimo/object.rb', line 45 def to_s format('<%s %s>', self.class, value) end |