Class: Drawght::Compiler
- Inherits:
-
Object
- Object
- Drawght::Compiler
- Includes:
- Parser
- Defined in:
- lib/drawght/compiler.rb
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
#mapping_placeholders_from, #pathkeys_from, #placeholders_from, #replace_placeholders, #sequential_placeholders, #straightly_placeholders
Constructor Details
#initialize(template, dataset = nil) ⇒ Compiler
Returns a new instance of Compiler.
13 14 15 16 17 |
# File 'lib/drawght/compiler.rb', line 13 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.
11 12 13 |
# File 'lib/drawght/compiler.rb', line 11 def dataset @dataset end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
11 12 13 |
# File 'lib/drawght/compiler.rb', line 11 def result @result end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
11 12 13 |
# File 'lib/drawght/compiler.rb', line 11 def template @template end |
Instance Method Details
#compile(dataset) ⇒ Object
19 20 21 22 |
# File 'lib/drawght/compiler.rb', line 19 def compile dataset @dataset ||= dataset.deep_stringify_keys! compile! end |
#compile! ⇒ Object
24 25 26 27 |
# File 'lib/drawght/compiler.rb', line 24 def compile! convert result end |