Class: Hbc::DSL::Container

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/cask/lib/hbc/dsl/container.rb

Constant Summary collapse

VALID_KEYS =
Set.new [
  :type,
  :nested,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pairs = {}) ⇒ Container

Returns a new instance of Container



14
15
16
17
18
19
20
21
22
23
24
# File 'Library/Homebrew/cask/lib/hbc/dsl/container.rb', line 14

def initialize(pairs = {})
  @pairs = pairs
  pairs.each do |key, value|
    raise "invalid container key: '#{key.inspect}'" unless VALID_KEYS.include?(key)
    send(:"#{key}=", value)
  end

  return if type.nil?
  return unless Hbc::Container.from_type(type).nil?
  raise "invalid container type: #{type.inspect}"
end

Instance Attribute Details

#pairsObject

Returns the value of attribute pairs



12
13
14
# File 'Library/Homebrew/cask/lib/hbc/dsl/container.rb', line 12

def pairs
  @pairs
end

Instance Method Details

#to_sObject



30
31
32
# File 'Library/Homebrew/cask/lib/hbc/dsl/container.rb', line 30

def to_s
  @pairs.inspect
end

#to_yamlObject



26
27
28
# File 'Library/Homebrew/cask/lib/hbc/dsl/container.rb', line 26

def to_yaml
  @pairs.to_yaml
end