Class: Inspec::Resources::PConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/resources/parse_config.rb

Direct Known Subclasses

PConfigFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content = nil, useropts = nil) ⇒ PConfig

Returns a new instance of PConfig.



46
47
48
49
50
51
52
53
# File 'lib/resources/parse_config.rb', line 46

def initialize(content = nil, useropts = nil)
  @opts = {}
  @opts = useropts.dup unless useropts.nil?
  @files_contents = {}

  @content = content
  read_params unless @content.nil?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



55
56
57
# File 'lib/resources/parse_config.rb', line 55

def method_missing(name)
  read_params[name.to_s]
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



45
46
47
# File 'lib/resources/parse_config.rb', line 45

def content
  @content
end

Instance Method Details

#params(*opts) ⇒ Object



59
60
61
62
63
# File 'lib/resources/parse_config.rb', line 59

def params(*opts)
  opts.inject(read_params) do |res, nxt|
    res.respond_to?(:key) ? res[nxt] : nil
  end
end

#to_sObject



65
66
67
# File 'lib/resources/parse_config.rb', line 65

def to_s
  "Parse Config #{@conf_path}"
end