Class: PuppetClass

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

Instance Method Summary collapse

Constructor Details

#initialize(tokens, index) ⇒ PuppetClass

Returns a new instance of PuppetClass.



5
6
7
# File 'lib/model/puppet_class.rb', line 5

def initialize(tokens, index)
  @tokens, @index = tokens, index
end

Instance Method Details

#documentation_listObject



26
27
28
# File 'lib/model/puppet_class.rb', line 26

def documentation_list
  @documentation_list ||= DocumentationList.new(documentation_tokens, @tokens.index(documentation_tokens.first), @tokens.index(documentation_tokens.last))
end

#has_parameter_documentation?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/model/puppet_class.rb', line 15

def has_parameter_documentation?
  !parameter_documentation_list.empty?
end

#nameObject



9
10
11
12
13
# File 'lib/model/puppet_class.rb', line 9

def name
  @name ||= @index[:tokens].select do |token|
    token.type == :NAME
  end.first.value
end

#parameter_documentation_end_indexObject



54
55
56
# File 'lib/model/puppet_class.rb', line 54

def parameter_documentation_end_index
  @tokens.index(parameter_documentation_list.last.tokens.last) + 1
end

#parameter_documentation_listObject



30
31
32
# File 'lib/model/puppet_class.rb', line 30

def parameter_documentation_list
  documentation_list.parameter_documentation_list
end

#parameter_documentation_start_indexObject



50
51
52
# File 'lib/model/puppet_class.rb', line 50

def parameter_documentation_start_index
  @tokens.index(parameter_documentation_list.first.tokens.first)
end

#parameter_listObject



19
20
21
22
23
24
# File 'lib/model/puppet_class.rb', line 19

def parameter_list
  param_tokens = @index[:param_tokens]
  return if param_tokens.nil?

  @parameter_list ||= ParameterList.new(param_tokens, @tokens.index(param_tokens.first), @tokens.index(param_tokens.last))
end

#sorted_parameter_documentation_listObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/model/puppet_class.rb', line 34

def sorted_parameter_documentation_list
  sorted_parameter_list.inject([]) do |memo, parameter|
    documentation = parameter_documentation_list.select do |parameter_documentation|
      parameter_documentation.name == parameter.name
    end.first

    memo << documentation if documentation

    memo
  end
end

#sorted_parameter_listObject



46
47
48
# File 'lib/model/puppet_class.rb', line 46

def sorted_parameter_list
  parameter_list.sort
end