Class: Init

Inherits:
Object
  • Object
show all
Defined in:
init.rb

Overview

Init is the entry class which manages the State Machine and creates all of it's states and transitions

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder) ⇒ Init


21
22
23
# File 'init.rb', line 21

def initialize(builder)
  self.builder = builder
end

Instance Attribute Details

#builderStateMachineBuilder


19
20
21
# File 'init.rb', line 19

def builder
  @builder
end

Instance Method Details

#clean_line(line) ⇒ Object (protected)


40
41
42
# File 'init.rb', line 40

def clean_line(line)
  line.strip
end

#parse_file(file_name) ⇒ nil

Extracts the lines from a file and executes the State Machine for each of these lines


29
30
31
32
33
34
35
36
# File 'init.rb', line 29

def parse_file(file_name)
  state_machine = builder.build
  File.foreach(file_name).with_index do |line, _line_num|
    builder.reset
    state_machine.line = clean_line(line)
    state_machine.execute
  end
end