Class: Drawght::Compiler

Inherits:
Object
  • Object
show all
Includes:
Parser, Tracker
Defined in:
lib/drawght/compiler.rb

Constant Summary

Constants included from Parser

Parser::ATTRIBUTE_MATCHES, Parser::ELEMENT_MATCHES, Parser::IDENTIFIER_MATCHES, Parser::INDEX_MATCHES, Parser::NUMBER_PATTERN, Parser::PLACEHOLDERS_PATTERN, Parser::SCOPE_PATH_PATTERN, Parser::SCOPE_TOKEN_PATTERN, Parser::STRUCTURE_TOKEN_PATTERN, Parser::TOKENS, Parser::VALIDATION_PATTERN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Parser

#has_placeholders?, #mapping_placeholders_from, #pathize, #pathkeys_from, #placeholders_from, #sequential_placeholders, #structural_placeholders, #syntax_valid?

Constructor Details

#initialize(template, dataset = nil) ⇒ Compiler

Returns a new instance of Compiler.



34
35
36
37
38
# File 'lib/drawght/compiler.rb', line 34

def initialize template, dataset = nil
  @template = template
  @result = template.dup
  @dataset = dataset.deep_stringify_keys! if dataset
end

Instance Attribute Details

#datasetObject (readonly)

Returns the value of attribute dataset.



32
33
34
# File 'lib/drawght/compiler.rb', line 32

def dataset
  @dataset
end

#resultObject (readonly)

Returns the value of attribute result.



32
33
34
# File 'lib/drawght/compiler.rb', line 32

def result
  @result
end

#templateObject (readonly)

Returns the value of attribute template.



32
33
34
# File 'lib/drawght/compiler.rb', line 32

def template
  @template
end

Instance Method Details

#compile(dataset) ⇒ Object



40
41
42
43
# File 'lib/drawght/compiler.rb', line 40

def compile dataset
  @dataset ||= dataset.deep_stringify_keys!
  compile!
end

#compile!Object



45
46
47
48
# File 'lib/drawght/compiler.rb', line 45

def compile!
  convert
  result
end