Class: Fable::Pointer
- Inherits:
-
Object
- Object
- Fable::Pointer
- Defined in:
- lib/fable/pointer.rb
Instance Attribute Summary collapse
-
#container ⇒ Object
Returns the value of attribute container.
-
#index ⇒ Object
Returns the value of attribute index.
Class Method Summary collapse
Instance Method Summary collapse
- #clone ⇒ Object
-
#initialize(container, index) ⇒ Pointer
constructor
A new instance of Pointer.
- #null_pointer? ⇒ Boolean
- #path ⇒ Object
- #resolve! ⇒ Object
Constructor Details
#initialize(container, index) ⇒ Pointer
Returns a new instance of Pointer.
13 14 15 16 |
# File 'lib/fable/pointer.rb', line 13 def initialize(container, index) self.container = container self.index = index end |
Instance Attribute Details
#container ⇒ Object
Returns the value of attribute container.
3 4 5 |
# File 'lib/fable/pointer.rb', line 3 def container @container end |
#index ⇒ Object
Returns the value of attribute index.
3 4 5 |
# File 'lib/fable/pointer.rb', line 3 def index @index end |
Class Method Details
.null_pointer ⇒ Object
9 10 11 |
# File 'lib/fable/pointer.rb', line 9 def self.null_pointer self.new(nil, -1) end |
.start_of(container) ⇒ Object
5 6 7 |
# File 'lib/fable/pointer.rb', line 5 def self.start_of(container) self.new(container, 0) end |
Instance Method Details
#clone ⇒ Object
25 26 27 |
# File 'lib/fable/pointer.rb', line 25 def clone self.class.new(self.container, self.index) end |
#null_pointer? ⇒ Boolean
29 30 31 |
# File 'lib/fable/pointer.rb', line 29 def null_pointer? container.nil? end |
#path ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/fable/pointer.rb', line 33 def path return nil if null_pointer? if index > 0 return container.path.path_by_appending_component(index) else return container.path end end |
#resolve! ⇒ Object
18 19 20 21 22 23 |
# File 'lib/fable/pointer.rb', line 18 def resolve! return container if index < 0 return nil if container.nil? return container if container.content.empty? return container.content[index] end |