Class: OsCtl::Image::Operations::Config::ParseAttrs
- Includes:
- Lib::Utils::Log, Lib::Utils::System
- Defined in:
- lib/osctl/image/operations/config/parse_attrs.rb
Instance Attribute Summary collapse
- #base_dir ⇒ String readonly
- #name ⇒ String readonly
- #type ⇒ Symbol readonly
Instance Method Summary collapse
- #execute ⇒ Hash
-
#initialize(base_dir, type, name) ⇒ ParseAttrs
constructor
A new instance of ParseAttrs.
Methods inherited from Base
Constructor Details
#initialize(base_dir, type, name) ⇒ ParseAttrs
Returns a new instance of ParseAttrs.
21 22 23 24 25 26 |
# File 'lib/osctl/image/operations/config/parse_attrs.rb', line 21 def initialize(base_dir, type, name) super() @base_dir = base_dir @type = type @name = name end |
Instance Attribute Details
#base_dir ⇒ String (readonly)
10 11 12 |
# File 'lib/osctl/image/operations/config/parse_attrs.rb', line 10 def base_dir @base_dir end |
#name ⇒ String (readonly)
16 17 18 |
# File 'lib/osctl/image/operations/config/parse_attrs.rb', line 16 def name @name end |
#type ⇒ Symbol (readonly)
13 14 15 |
# File 'lib/osctl/image/operations/config/parse_attrs.rb', line 13 def type @type end |
Instance Method Details
#execute ⇒ Hash
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/osctl/image/operations/config/parse_attrs.rb', line 30 def execute ret = {} syscmd([ File.join(base_dir, 'bin', 'config'), type.to_s, 'show', name ].join(' ')).output.split("\n").each do |line| eq = line.index('=') next if eq.nil? var = line[0..eq - 1] val = line[eq + 1..] next if val.empty? ret[var] = val end ret end |