Class: YAML::DomainType

Inherits:
Object show all
Defined in:
lib/cfoo/yaml.rb,
lib/cfoo/parser.rb

Constant Summary collapse

CLOUDFORMATION_FUNCTION_REGEX =
%r[^(#{::Cfoo::CLOUDFORMATION_FUNCTIONS.join '|'})$]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#domainObject

Returns the value of attribute domain.



12
13
14
# File 'lib/cfoo/yaml.rb', line 12

def domain
  @domain
end

#type_idObject

Returns the value of attribute type_id.



12
13
14
# File 'lib/cfoo/yaml.rb', line 12

def type_id
  @type_id
end

#valueObject

Returns the value of attribute value.



12
13
14
# File 'lib/cfoo/yaml.rb', line 12

def value
  @value
end

Class Method Details

.create(type_id, value) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/cfoo/yaml.rb', line 14

def self.create(type_id, value)
    type = self.allocate
    type.domain = "yaml.org,2002"
    type.type_id = type_id
    type.value = value
    type
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/cfoo/yaml.rb', line 22

def ==(other)
    eq? other
end

#eq?(other) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
# File 'lib/cfoo/yaml.rb', line 26

def eq?(other)
    if other.respond_to?(:domain) && other.respond_to?(:type_id) && other.respond_to?(:value)
        domain == other.domain && type_id == other.type_id && value == other.value
    else
        false
    end
end

#expand_elObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/cfoo/parser.rb', line 64

def expand_el
    case type_id
    when "Ref"
        { "Ref" => value.expand_el }
    when "GetAZs"
        if value.nil?
            { "Fn::GetAZs" => "" }
        else
            { "Fn::GetAZs" => value.expand_el }
        end
    when CLOUDFORMATION_FUNCTION_REGEX
        { "Fn::#{type_id}" => value.expand_el }
    when "Concat"
        { "Fn::Join" => ['', value.expand_el] }
    else
        super
    end 
end