Class: Mucks::BaseConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/mucks/mucks.rb

Direct Known Subclasses

LayoutConfig, SessionConfig

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ BaseConfig

Returns a new instance of BaseConfig.



14
15
16
17
# File 'lib/mucks/mucks.rb', line 14

def initialize(path)
  @config = SystemIO.load_yaml(File.expand_path(path))
  show_self if Config.verbose
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/mucks/mucks.rb', line 13

def config
  @config
end

Instance Method Details

#show_selfObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mucks/mucks.rb', line 19

def show_self
  Output.wrap_with(self.class) do
    s = ''
    @config.each do |key, value|
      s += "#{key} => "
      if value.is_a?(Array) then
        s += stringify_elements_for(value)
      else
        s += "\n"
        s += "  #{value}}\n"
      end
    end
    puts s
  end
end

#stringify_elements_for(array) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/mucks/mucks.rb', line 35

def stringify_elements_for(array)
  s = "[\n"
  array.each do |element|
    s += "  #{element.inspect},\n"
  end
  s += "]\n"
end