Class: Terminitor::Yaml
- Inherits:
-
Object
- Object
- Terminitor::Yaml
- Defined in:
- lib/terminitor/yaml.rb
Overview
This class holds the legacy YAML sytnax for Terminitor
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(path) ⇒ Yaml
constructor
Load in the Yaml file…
-
#to_hash ⇒ Hash
Returns yaml file as Terminitor formmatted hash.
Constructor Details
#initialize(path) ⇒ Yaml
Load in the Yaml file…
10 11 12 |
# File 'lib/terminitor/yaml.rb', line 10 def initialize(path) @file = YAML.load File.read(path) end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
6 7 8 |
# File 'lib/terminitor/yaml.rb', line 6 def file @file end |
Instance Method Details
#to_hash ⇒ Hash
Returns yaml file as Terminitor formmatted hash
16 17 18 19 20 21 22 23 |
# File 'lib/terminitor/yaml.rb', line 16 def to_hash combined = @file.inject({}) do |base, item| item = {item.keys.first => {:commands => item.values.first, :options => {}}} base.merge!(item) base end # merge the array of hashes. { :setup => nil, :windows => { 'default' => {:tabs => combined} } } end |