Class: StateMachine::OOStructuredFSM::ClassState

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

Overview

Class responsible for handling class state.

Instance Method Summary collapse

Methods inherited from OOStructuredState

#class_capture, #conditional_capture, #function_capture, #include_capture, #repetition_capture, #variable_capture

Constructor Details

#initialize(pLanguage) ⇒ ClassState



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

def initialize (pLanguage)
  @language = pLanguage
end

Instance Method Details

#aggregation_captureObject



66
67
68
# File 'lib/kuniri/state_machine/OO_structured_fsm/class_state.rb', line 66

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

#attribute_captureObject

See Also:



47
48
49
# File 'lib/kuniri/state_machine/OO_structured_fsm/class_state.rb', line 47

def attribute_capture
  @language.set_state(@language.attributeState)
end

#comment_captureObject

See Also:



62
63
64
# File 'lib/kuniri/state_machine/OO_structured_fsm/class_state.rb', line 62

def comment_capture
  @language.set_state(@language.commentState)
end

#constructor_captureObject

See Also:



42
43
44
# File 'lib/kuniri/state_machine/OO_structured_fsm/class_state.rb', line 42

def constructor_capture
  @language.set_state(@language.constructorState)
end

#execute(pElementFile, pLine) ⇒ Object

See Also:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/kuniri/state_machine/OO_structured_fsm/class_state.rb', line 71

def execute(pElementFile, pLine)
  classElement = @language.classHandler.get_class(pLine)

  if classElement
    classElement.comments = @language.string_comment_to_transfer
    @language.string_comment_to_transfer = ""
    pElementFile.add_class(classElement)
    @language..allClasses.push(classElement)
  end

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

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

  return pElementFile
end

#handle_line(pLine) ⇒ Object

See Also:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/kuniri/state_machine/OO_structured_fsm/class_state.rb', line 17

def handle_line(pLine)
  if @language.aggregationHandler.get_aggregation(pLine)
    aggregation_capture
  elsif @language.attributeHandler.get_attribute(pLine)
    attribute_capture
  elsif @language.constructorHandler.get_constructor(pLine)
    constructor_capture
  elsif @language.methodHandler.get_function(pLine)
    method_capture
  elsif @language.moduleHandler.get_module(pLine)
    module_capture
  elsif @language.aggregationHandler.get_aggregation(pLine)
    aggregation_capture
  elsif @language.commentHandler.is_single_line_comment?(pLine) ||
        @language.commentHandler.is_multiple_line_comment?(pLine)
    comment_capture
  end
end

#idle_captureObject

See Also:



57
58
59
# File 'lib/kuniri/state_machine/OO_structured_fsm/class_state.rb', line 57

def idle_capture
  @language.rewind_state
end

#method_captureObject

See Also:



37
38
39
# File 'lib/kuniri/state_machine/OO_structured_fsm/class_state.rb', line 37

def method_capture
  @language.set_state(@language.methodState)
end

#module_captureObject

See Also:



52
53
54
# File 'lib/kuniri/state_machine/OO_structured_fsm/class_state.rb', line 52

def module_capture
  @language.rewind_state
end