Class: StringNode
Overview
See ArrayNode for a more complete Data Structure
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
- #*(other) ⇒ Object
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #/(other) ⇒ Object
- #contains?(other) ⇒ Boolean
- #evaluate ⇒ Object
-
#initialize(value) ⇒ StringNode
constructor
A new instance of StringNode.
- #to_f ⇒ Object
- #to_i ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(value) ⇒ StringNode
Returns a new instance of StringNode.
50 51 52 53 54 55 56 |
# File 'lib/nodes/basenodes.rb', line 50 def initialize(value) if value.is_a?(String) super else super(value.join(' ')) end end |
Instance Method Details
#*(other) ⇒ Object
66 67 68 |
# File 'lib/nodes/basenodes.rb', line 66 def *(other) raise NotImplementedError, 'Multiplication is not implemented for Strings.' end |
#+(other) ⇒ Object
58 59 60 |
# File 'lib/nodes/basenodes.rb', line 58 def +(other) raise NotImplementedError, 'Addition is not implemented for Strings.' end |
#-(other) ⇒ Object
62 63 64 |
# File 'lib/nodes/basenodes.rb', line 62 def -(other) raise NotImplementedError, 'Subtraction is not implemented for Strings.' end |
#/(other) ⇒ Object
70 71 72 |
# File 'lib/nodes/basenodes.rb', line 70 def /(other) raise NotImplementedError, 'Division is not implemented for Strings.' end |
#contains?(other) ⇒ Boolean
82 83 84 |
# File 'lib/nodes/basenodes.rb', line 82 def contains?(other) return if @value.include?(other) end |
#evaluate ⇒ Object
86 87 88 |
# File 'lib/nodes/basenodes.rb', line 86 def evaluate self end |
#to_f ⇒ Object
78 79 80 |
# File 'lib/nodes/basenodes.rb', line 78 def to_f @value.to_f end |
#to_i ⇒ Object
74 75 76 |
# File 'lib/nodes/basenodes.rb', line 74 def to_i @value.to_i end |