class Mhc::Config::List

Parse Array object in YAML

Public Class Methods

new(item_class, array = []) click to toggle source
# File lib/mhc/config.rb, line 139
def initialize(item_class, array = [])
  @original_hash = array
  @configs = []
  (array || []).each do |value|
    item = item_class.new(value)
    @configs << item
  end
end

Public Instance Methods

<<(conf) click to toggle source
# File lib/mhc/config.rb, line 154
def <<(conf)
  @configs << conf
end
[](key) click to toggle source
# File lib/mhc/config.rb, line 148
def [](key)
  @configs.find {|c| c.name == key}
end
Also aliased as: get_subnode
each() { |conf| ... } click to toggle source
# File lib/mhc/config.rb, line 162
def each
  @configs.each do |conf|
    yield conf
  end
end
get_subnode(key)
Alias for: []
to_hash() click to toggle source
# File lib/mhc/config.rb, line 158
def to_hash # XXX: actually, it returns a Array
  return @configs.map {|c| c.respond_to?(:to_hash) ? c.to_hash : c.to_s}
end