Class: KiskoSuits::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/kisko-suits/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Compiler

Returns a new instance of Compiler.



7
8
9
10
11
12
13
# File 'lib/kisko-suits/compiler.rb', line 7

def initialize(path)
  @path = path
  @output_filename = nil

  @included_filenames = Set.new
  @variables = {}
end

Instance Attribute Details

#included_filenamesObject (readonly)

Returns the value of attribute included_filenames.



5
6
7
# File 'lib/kisko-suits/compiler.rb', line 5

def included_filenames
  @included_filenames
end

#output_filenameObject (readonly)

Returns the value of attribute output_filename.



5
6
7
# File 'lib/kisko-suits/compiler.rb', line 5

def output_filename
  @output_filename
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/kisko-suits/compiler.rb', line 5

def path
  @path
end

Instance Method Details

#renderObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kisko-suits/compiler.rb', line 15

def render
  @included_filenames.clear
  @variables.clear

  abort "Suits file '#{path}' not found" unless File.exists?(path)

  open_output_file do |output|
    File.foreach(path).each do |line|
      output.write(process_line(File.dirname(path), line))
    end
  end
end