Class: StateMachine::OOStructuredFSM::MethodState

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

Overview

Class responsible for handling Method state.

Instance Method Summary collapse

Methods inherited from OOStructuredState

#attribute_capture, #comment_capture, #constructor_capture, #function_capture, #idle_capture, #include_capture, #method_capture, #module_capture, #variable_capture

Constructor Details

#initialize(pLanguage) ⇒ MethodState

Returns a new instance of MethodState.



12
13
14
# File 'lib/kuniri/state_machine/OO_structured_fsm/method_state.rb', line 12

def initialize(pLanguage)
  @language = pLanguage
end

Instance Method Details

#class_captureObject

See Also:



28
29
30
# File 'lib/kuniri/state_machine/OO_structured_fsm/method_state.rb', line 28

def class_capture
  @language.rewind_state
end

#conditional_captureObject

See Also:



33
34
35
36
# File 'lib/kuniri/state_machine/OO_structured_fsm/method_state.rb', line 33

def conditional_capture
  @language.flagFunctionBehaviour = StateMachine::METHOD_STATE
  @language.set_state(@language.conditionalState)
end

#execute(pElementFile, pLine) ⇒ Object

See Also:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/kuniri/state_machine/OO_structured_fsm/method_state.rb', line 45

def execute(pElementFile, pLine)
  methodElement = @language.methodHandler.get_function(pLine)

  if (methodElement)
    lastIndex = pElementFile.classes.length - 1 # We want the index
    methodElement.comments = @language.string_comment_to_transfer
    @language.string_comment_to_transfer = ""
    pElementFile.classes[lastIndex].add_method(methodElement)
  end

  if (@language.endBlockHandler.has_end_of_block?(pLine))
    class_capture
  end

  return pElementFile
end

#handle_line(pLine) ⇒ Object

See Also:



17
18
19
20
21
22
23
24
25
# File 'lib/kuniri/state_machine/OO_structured_fsm/method_state.rb', line 17

def handle_line(pLine)
  if @language.conditionalHandler.get_conditional(pLine)
    conditional_capture
  elsif @language.repetitionHandler.get_repetition(pLine)
    repetition_capture
  else
    return
  end
end

#repetition_captureObject

See Also:



39
40
41
42
# File 'lib/kuniri/state_machine/OO_structured_fsm/method_state.rb', line 39

def repetition_capture
  @language.flagFunctionBehaviour = StateMachine::METHOD_STATE
  @language.set_state(@language.repetitionState)
end