Class: DocumentationList

Inherits:
Object
  • Object
show all
Defined in:
lib/model/documentation_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tokens, start_index, end_index) ⇒ DocumentationList

Returns a new instance of DocumentationList.



6
7
8
# File 'lib/model/documentation_list.rb', line 6

def initialize(tokens, start_index, end_index)
  @tokens, @start_index, @end_index = tokens, start_index, end_index
end

Instance Attribute Details

#end_indexObject (readonly)

Returns the value of attribute end_index.



4
5
6
# File 'lib/model/documentation_list.rb', line 4

def end_index
  @end_index
end

#start_indexObject (readonly)

Returns the value of attribute start_index.



4
5
6
# File 'lib/model/documentation_list.rb', line 4

def start_index
  @start_index
end

Instance Method Details

#parameter_documentation_listObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/model/documentation_list.rb', line 10

def parameter_documentation_list
  return @parameter_documentation_list unless @parameter_documentation_list.nil?

  parameter_documentation = ParameterDocumentation.new
  harvest_tokens = false

  @parameter_documentation_list = @tokens.inject([]) do |memo, token|
    if token.type == :COMMENT && token.value.match(/@param \w*/)
      memo << parameter_documentation if parameter_documentation.tokens.any?
      parameter_documentation = ParameterDocumentation.new
      harvest_tokens = true
    end

    if (token.type == :COMMENT && token.value.strip == "")
      harvest_tokens = false
    end

    if harvest_tokens
      parameter_documentation.tokens << token
    end

    memo
  end

  @parameter_documentation_list << parameter_documentation if parameter_documentation.tokens.any?

  @parameter_documentation_list
end