Module: CodeObject::Converter

Included in:
Parser::Comment
Defined in:
lib/code_object/converter.rb

Overview

Converts a comment to a code_object and therefor is included in Parser::Comment

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#code_objectObject (readonly)

Returns the value of attribute code_object.



8
9
10
# File 'lib/code_object/converter.rb', line 8

def code_object
  @code_object
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/code_object/converter.rb', line 8

def path
  @path
end

Instance Method Details

#to_code_objectObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/code_object/converter.rb', line 10

def to_code_object

  # 1. Create a new CodeObject from Type-Token like @function -> CodeObject::Function 
  @code_object = find_type_for(@tokenlines) or return nil
        
  # join all documentation-contents and make them one text again
  @code_object.docs = @doclines.join ''     
  
  # move meta-information from comment to code_object
  # (This includes filepath, source and line_start
  @code_object.clone_meta(self)
       
  # 2. Process Tokenlines with registered handlers
  @code_object.process_tokens(@tokenlines)
  
  # 3.Continue with all children of this comment and add them as
  #   child nodes
  convert_children { |child| @code_object.add_node(child) }
  
  return @code_object
end