Class: Inspec::Resources::PConfig

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

Direct Known Subclasses

PConfigFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileReader

#read_file_content

Constructor Details

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

Returns a new instance of PConfig.



49
50
51
52
53
54
55
56
# File 'lib/inspec/resources/parse_config.rb', line 49

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



58
59
60
# File 'lib/inspec/resources/parse_config.rb', line 58

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

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



48
49
50
# File 'lib/inspec/resources/parse_config.rb', line 48

def content
  @content
end

Instance Method Details

#params(*opts) ⇒ Object



62
63
64
65
66
# File 'lib/inspec/resources/parse_config.rb', line 62

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

#to_sObject



68
69
70
# File 'lib/inspec/resources/parse_config.rb', line 68

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