Class: PuppetClass
- Inherits:
-
Object
- Object
- PuppetClass
- Defined in:
- lib/model/puppet_class.rb
Instance Method Summary collapse
- #documentation_list ⇒ Object
- #has_parameter_documentation? ⇒ Boolean
-
#initialize(tokens, index) ⇒ PuppetClass
constructor
A new instance of PuppetClass.
- #name ⇒ Object
- #parameter_documentation_end_index ⇒ Object
- #parameter_documentation_list ⇒ Object
- #parameter_documentation_start_index ⇒ Object
- #parameter_list ⇒ Object
- #sorted_parameter_documentation_list ⇒ Object
- #sorted_parameter_list ⇒ Object
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_list ⇒ Object
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
15 16 17 |
# File 'lib/model/puppet_class.rb', line 15 def has_parameter_documentation? !parameter_documentation_list.empty? end |
#name ⇒ Object
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_index ⇒ Object
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_list ⇒ Object
30 31 32 |
# File 'lib/model/puppet_class.rb', line 30 def parameter_documentation_list documentation_list.parameter_documentation_list end |
#parameter_documentation_start_index ⇒ Object
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_list ⇒ Object
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_list ⇒ Object
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_list ⇒ Object
46 47 48 |
# File 'lib/model/puppet_class.rb', line 46 def sorted_parameter_list parameter_list.sort end |