Class: Facter::Util::Parser::Base
- Inherits:
-
Object
- Object
- Facter::Util::Parser::Base
- Defined in:
- lib/facter/util/parser.rb
Direct Known Subclasses
JsonParser, PowershellParser, ScriptParser, TextParser, YamlParser
Instance Attribute Summary collapse
- #filename ⇒ Object readonly
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(filename, content = nil) ⇒ Base
constructor
A new instance of Base.
- #parse_results ⇒ Object
-
#results ⇒ Object
results on the base class is really meant to be just an exception handler wrapper.
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
#filename ⇒ Object (readonly)
42 43 44 |
# File 'lib/facter/util/parser.rb', line 42 def filename @filename end |
Instance Method Details
#content ⇒ Object
49 50 51 |
# File 'lib/facter/util/parser.rb', line 49 def content @content ||= File.read(filename) end |
#parse_results ⇒ Object
62 63 64 |
# File 'lib/facter/util/parser.rb', line 62 def parse_results raise ArgumentError, "Subclasses must respond to parse_results" end |
#results ⇒ Object
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.}") nil end |