class CfScript::AttributeList

Public Class Methods

new(attributes = []) click to toggle source
# File lib/cf_script/object/attribute_list.rb, line 7
def initialize(attributes = [])
  @list = {}

  attributes.each do |attribute|
    self << attribute
  end
end

Public Instance Methods

<<(attr) click to toggle source
# File lib/cf_script/object/attribute_list.rb, line 23
def <<(attr)
  if @list.key?(attr.name)
    raise "Duplicate attribute '#{attr.name}'"
  end

  @list[attr.name] = attr
end
names() click to toggle source
# File lib/cf_script/object/attribute_list.rb, line 15
def names
  @list.keys
end
to_h() click to toggle source
# File lib/cf_script/object/attribute_list.rb, line 31
def to_h
  hash = {}

  @list.each do |name, attr|
    hash[name] = attr.value
  end

  hash
end
values() click to toggle source
# File lib/cf_script/object/attribute_list.rb, line 19
def values
  @list.values.map { |attr| attr.value }
end