Class: Ptolemy::TOML::ArrayLiteral

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/ptolemy/nodes.rb

Overview

Represents a homogeneous array. Mixing of types is not allowed for elements of an array.

  • 1, 2, 3, 4
  • “Hello”, “World”
  • [“Alpha”, “Beta”], [1, 2]

    <– This is fine

Instance Method Summary collapse

Instance Method Details

#to_valueArray

Evaluate the array by mapping the individual elements of the array to their evaluated selves.

Returns:

  • (Array)

    evaluated array



110
111
112
113
114
115
116
117
118
# File 'lib/ptolemy/nodes.rb', line 110

def to_value
  result = list.elements.map do|elem|
    elem.item.to_value
  end
  unless last.empty?
    result << last.item.to_value
  end
  result
end