Class: GuidedPath::TextNode

Inherits:
Node
  • Object
show all
Defined in:
lib/guided_path/text_node.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#label, #next_node

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ TextNode

Returns a new instance of TextNode.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
# File 'lib/guided_path/text_node.rb', line 9

def initialize(args = {})
  super
  args = args.symbolize_keys

  raise(ArgumentError, "Must specify a value for the node") unless args[:value]
  @value = args[:value].to_s
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/guided_path/text_node.rb', line 7

def value
  @value
end

Instance Method Details

#to_hashObject



18
19
20
21
22
23
# File 'lib/guided_path/text_node.rb', line 18

def to_hash
  output = super
  output[:type] = 'text'
  output[:value] = @value
  output
end