class TL1::AST::CommaSeparatedVariables
A group of fields separated by commas with a fixed order.
Public Class Methods
new(*fields)
click to toggle source
# File lib/tl1/ast.rb, line 147 def initialize(*fields) @fields = fields end
parse(source)
click to toggle source
# File lib/tl1/ast.rb, line 136 def self.parse(source) elements = if source.is_a?(String) AST.split(source, ',').map { |e| Variable.parse(e) } else source.map { |e| Variable.parse(e['fields']) } end new(*elements) end
Public Instance Methods
as_json()
click to toggle source
Calls superclass method
TL1::AST::Node#as_json
# File lib/tl1/ast.rb, line 151 def as_json super(fields.map(&:as_json)) end
format(**kwargs)
click to toggle source
# File lib/tl1/ast.rb, line 155 def format(**kwargs) fields.map { |f| f.format(**kwargs) }.join(',') end
parse(source, record:)
click to toggle source
# File lib/tl1/ast.rb, line 159 def parse(source, record:) AST.split(source, ',').zip(fields).each do |value, field| field.parse(value, record: record) end record end