Class: Masamune::Transform::Operator
- Inherits:
-
Object
- Object
- Masamune::Transform::Operator
- Defined in:
- lib/masamune/transform/operator.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ Operator
constructor
A new instance of Operator.
- #to_file ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Operator
25 26 27 28 29 |
# File 'lib/masamune/transform/operator.rb', line 25 def initialize(*args) = args.last.is_a?(Hash) ? args.pop : {} @templates = args = end |
Instance Method Details
#to_file ⇒ Object
44 45 46 47 48 49 |
# File 'lib/masamune/transform/operator.rb', line 44 def to_file Tempfile.create('masamune_operator').tap do |file| file.write(to_s) file.close end.path end |
#to_s ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/masamune/transform/operator.rb', line 31 def to_s result = [] @templates.each do |template| case template when Operator result << template when Symbol, String result << template_eval(template) end end Masamune::Template.combine(*result) end |