Class: Drawght::Compiler
- Inherits:
-
Object
- Object
- Drawght::Compiler
- 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
-
#dataset ⇒ Object
readonly
Returns the value of attribute dataset.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #compile(dataset) ⇒ Object
- #compile! ⇒ Object
-
#initialize(template, dataset = nil) ⇒ Compiler
constructor
A new instance of Compiler.
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
#dataset ⇒ Object (readonly)
Returns the value of attribute dataset.
32 33 34 |
# File 'lib/drawght/compiler.rb', line 32 def dataset @dataset end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
32 33 34 |
# File 'lib/drawght/compiler.rb', line 32 def result @result end |
#template ⇒ Object (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 |