Class: Masamune::Transform::Operator

Inherits:
Object
  • Object
show all
Defined in:
lib/masamune/transform/operator.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Operator



25
26
27
28
29
# File 'lib/masamune/transform/operator.rb', line 25

def initialize(*args)
  options     = args.last.is_a?(Hash) ? args.pop : {}
  @templates  = args
  @options    = options
end

Instance Method Details

#to_fileObject



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_sObject



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