Class: Streamer::FactProviders::YamlProvider
- Inherits:
-
Object
- Object
- Streamer::FactProviders::YamlProvider
- Extended by:
- Forwardable
- Defined in:
- lib/streamer/fact_providers/yaml_provider.rb
Overview
YamlProvider provides data from a yaml file
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(path: nil, yaml: nil) ⇒ YamlProvider
constructor
A new instance of YamlProvider.
- #load_file(path) ⇒ Object
- #load_yaml(yaml) ⇒ Object
- #provider ⇒ Object
Constructor Details
#initialize(path: nil, yaml: nil) ⇒ YamlProvider
Returns a new instance of YamlProvider.
10 11 12 13 |
# File 'lib/streamer/fact_providers/yaml_provider.rb', line 10 def initialize(path: nil, yaml: nil) load_file(path) if path load_yaml(yaml) if yaml end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/streamer/fact_providers/yaml_provider.rb', line 7 def data @data end |
Instance Method Details
#load_file(path) ⇒ Object
15 16 17 |
# File 'lib/streamer/fact_providers/yaml_provider.rb', line 15 def load_file(path) @data = YAML.load(File.read(path)) end |
#load_yaml(yaml) ⇒ Object
19 20 21 |
# File 'lib/streamer/fact_providers/yaml_provider.rb', line 19 def load_yaml(yaml) @data = YAML.load(yaml) end |
#provider ⇒ Object
23 24 25 |
# File 'lib/streamer/fact_providers/yaml_provider.rb', line 23 def provider @provider ||= HashProvider.new(data) end |