Class: PuppetStrings::Yard::CodeObjects::Provider

Inherits:
Base
  • Object
show all
Defined in:
lib/puppet-strings/yard/code_objects/provider.rb

Overview

Implements the Puppet provider code object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

new

Constructor Details

#initialize(type_name, name) ⇒ void

Initializes a Puppet provider code object.



28
29
30
31
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 28

def initialize(type_name, name)
  @type_name = type_name
  super(PuppetStrings::Yard::CodeObjects::Providers.instance(type_name), name)
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



22
23
24
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22

def commands
  @commands
end

#confinesObject (readonly)

Returns the value of attribute confines.



22
23
24
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22

def confines
  @confines
end

#defaultsObject (readonly)

Returns the value of attribute defaults.



22
23
24
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22

def defaults
  @defaults
end

#featuresObject (readonly)

Returns the value of attribute features.



22
23
24
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22

def features
  @features
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



22
23
24
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 22

def type_name
  @type_name
end

Instance Method Details

#add_command(key, value) ⇒ void

This method returns an undefined value.

Adds a command to the provider.



72
73
74
75
76
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 72

def add_command(key, value)
  return unless key && value
  @commands ||= {}
  @commands[key] = value
end

#add_confine(key, value) ⇒ void

This method returns an undefined value.

Adds a confine to the provider.



43
44
45
46
47
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 43

def add_confine(key, value)
  return unless key && value
  @confines ||= {}
  @confines[key] = value
end

#add_default(key, value) ⇒ void

This method returns an undefined value.

Adds a default to the provider.



62
63
64
65
66
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 62

def add_default(key, value)
  return unless key && value
  @defaults ||= {}
  @defaults[key] = value
end

#add_feature(feature) ⇒ void

This method returns an undefined value.

Adds a feature to the provider.



52
53
54
55
56
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 52

def add_feature(feature)
  return unless feature
  @features ||= []
  @features << feature
end

#to_hashHash

Converts the code object to a hash representation.



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 80

def to_hash
  hash = {}
  hash[:name] = name
  hash[:type_name] = type_name
  hash[:file] = file
  hash[:line] = line
  hash[:docstring] = PuppetStrings::Json.docstring_to_hash(docstring)
  hash[:confines] = confines if confines && !confines.empty?
  hash[:features] = features if features && !features.empty?
  hash[:defaults] = defaults if defaults && !defaults.empty?
  hash[:commands] = commands if commands && !commands.empty?
  hash
end

#typeObject

Gets the type of the code object.



35
36
37
# File 'lib/puppet-strings/yard/code_objects/provider.rb', line 35

def type
  :puppet_provider
end