Class: Facter::Util::Parser::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/util/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, content = nil) ⇒ Base

Returns a new instance of Base.



44
45
46
47
# File 'lib/facter/util/parser.rb', line 44

def initialize(filename, content = nil)
  @filename = filename
  @content  = content
end

Instance Attribute Details

#filenameObject (readonly)



42
43
44
# File 'lib/facter/util/parser.rb', line 42

def filename
  @filename
end

Instance Method Details

#contentObject



49
50
51
# File 'lib/facter/util/parser.rb', line 49

def content
  @content ||= File.read(filename)
end

#parse_resultsObject

Raises:

  • (ArgumentError)


62
63
64
# File 'lib/facter/util/parser.rb', line 62

def parse_results
  raise ArgumentError, "Subclasses must respond to parse_results"
end

#resultsObject

results on the base class is really meant to be just an exception handler wrapper.



55
56
57
58
59
60
# File 'lib/facter/util/parser.rb', line 55

def results
  parse_results
rescue Exception => detail
  Facter.log_exception(detail, "Failed to handle #{filename} as #{self.class} facts: #{detail.message}")
  nil
end