Class: StateMachine::OOStructuredFSM::FunctionBehaviourState

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

Overview

Class responsible for handling Method and constructor state.

Direct Known Subclasses

ConstructorState, MethodState

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, pParams = {}) ⇒ FunctionBehaviourState

Constructor responsible for setup the basic configuration.

Parameters:

  • pLanguage

    Reference to language object.

  • pParams (defaults to: {})

    Dictionary with all element data.



18
19
20
21
22
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb', line 18

def initialize(pLanguage, pParams = {})
  @language = pLanguage
  @flagState = pParams[:flagState] || StateMachine::METHOD_STATE
  @functionIdentifier = pParams[:functionId] || MethodState::METHOD_LABEL
end

Instance Method Details

#aggregation_captureObject

See Also:



55
56
57
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb', line 55

def aggregation_capture
  @language.set_state(@language.aggregationState)
end

#class_captureObject

See Also:



38
39
40
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb', line 38

def class_capture
  @language.rewind_state
end

#conditional_captureObject

See Also:



43
44
45
46
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb', line 43

def conditional_capture
  @language.flagFunctionBehaviour = @flagState
  @language.set_state(@language.conditionalState)
end

#execute(pElementFile, pLine) ⇒ Object

See Also:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb', line 60

def execute(pElementFile, pLine)
  functionElement = @language.send("#{@functionIdentifier}Handler")
                             .send("get_#{@functionIdentifier}", pLine)

  if (functionElement)
    lastIndex = pElementFile.classes.length - 1 # We want the index
    functionElement.comments = @language.string_comment_to_transfer
    @language.string_comment_to_transfer = ""
    pElementFile.classes[lastIndex].send("add_#{@functionIdentifier}",
                                         functionElement)
  end

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

  return pElementFile
end

#handle_line(pLine) ⇒ Object

See Also:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb', line 25

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

#repetition_captureObject

See Also:



49
50
51
52
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb', line 49

def repetition_capture
  @language.flagFunctionBehaviour = @flagState
  @language.set_state(@language.repetitionState)
end