Module: CodeObject::Converter

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

Overview

here the dependencies to Dom::Node and Parser::Comment should be described

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.



10
11
12
# File 'lib/code_object/converter.rb', line 10

def code_object
  @code_object
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/code_object/converter.rb', line 10

def path
  @path
end

Instance Method Details

#to_code_objectObject



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

def to_code_object

  # 1. Create a new CodeObject from Type-Token   
  @code_object = find_type_for(@tokenlines) or return nil
        
  # join all documentation-contents
  @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