Class: StateMachine::OOStructuredFSM::ModuleState

Inherits:
OOStructuredState show all
Defined in:
lib/kuniri/state_machine/OO_structured_fsm/module_state.rb

Overview

Class responsible for handling Module state.

Instance Method Summary collapse

Methods inherited from OOStructuredState

#aggregation_capture, #attribute_capture, #comment_capture, #conditional_capture, #constructor_capture, #include_capture, #method_capture, #module_capture, #repetition_capture

Constructor Details

#initialize(pLanguage) ⇒ ModuleState

Returns a new instance of ModuleState.



15
16
17
# File 'lib/kuniri/state_machine/OO_structured_fsm/module_state.rb', line 15

def initialize(pLanguage)
  @language = pLanguage
end

Instance Method Details

#class_captureObject

See Also:



36
37
38
# File 'lib/kuniri/state_machine/OO_structured_fsm/module_state.rb', line 36

def class_capture
  @language.set_state(@language.classState)
end

#execute(pElementFile, pLine) ⇒ Object

See Also:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/kuniri/state_machine/OO_structured_fsm/module_state.rb', line 51

def execute(pElementFile, pLine)

  moduleElement = @language.moduleHandler.get_module(pLine)

  if moduleElement
    pElementFile.add_modules(moduleElement)
  end

  if @language.endBlockHandler.has_end_of_block?(pLine)
    previous = @language.previousState.last

    if (previous.is_a?(StateMachine::OOStructuredFSM::IdleState))
      idle_capture
    else
      return pElementFile
    end
  end

  return pElementFile
end

#function_captureObject

See Also:



46
47
48
# File 'lib/kuniri/state_machine/OO_structured_fsm/module_state.rb', line 46

def function_capture
  @language.set_state(@language.functionState)
end

#handle_line(pLine) ⇒ Object

See Also:



20
21
22
23
24
25
26
27
28
# File 'lib/kuniri/state_machine/OO_structured_fsm/module_state.rb', line 20

def handle_line(pLine)
  if @language.classHandler.get_class(pLine)
    class_capture
  elsif @language.functionHandler.get_function(pLine)
    function_capture
  elsif @language.variableHandler.get_variable(pLine)
    variable_capture
  end
end

#idle_captureObject

See Also:



31
32
33
# File 'lib/kuniri/state_machine/OO_structured_fsm/module_state.rb', line 31

def idle_capture
  @language.set_state(@language.idleState)
end

#variable_captureObject

See Also:



41
42
43
# File 'lib/kuniri/state_machine/OO_structured_fsm/module_state.rb', line 41

def variable_capture
  @language.set_state(@language.variableState)
end