Class: Momo::BooleanValue

Inherits:
FuncCall show all
Includes:
MomoCondition
Defined in:
lib/momo/momoscope.rb

Instance Method Summary collapse

Methods included from MomoCondition

#and, #equals, #or

Methods inherited from FuncCall

#representation

Constructor Details

#initialize(operator, stack, *args) ⇒ BooleanValue

Returns a new instance of BooleanValue.



73
74
75
76
# File 'lib/momo/momoscope.rb', line 73

def initialize(operator, stack, *args)
	super(operator, stack, args)
	stack.conditions[self.signature] = self.representation
end

Instance Method Details

#either(val_true, val_false) ⇒ Object



82
83
84
# File 'lib/momo/momoscope.rb', line 82

def either(val_true, val_false)
	FuncCall.new("Fn::If", @stack, self.signature, val_true, val_false)
end

#notObject



78
79
80
# File 'lib/momo/momoscope.rb', line 78

def not()
	BooleanValue.new("Fn::Not", @stack, self)
end

#signatureObject



101
102
103
104
# File 'lib/momo/momoscope.rb', line 101

def signature()
	match = /Fn::(?<name>[a-z]+)/i.match(@name)
	"#{signature_of(@args[0])}#{match[:name]}#{signature_of(@args[1])}"
end

#signature_of(something) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/momo/momoscope.rb', line 86

def signature_of(something)
	if something.is_a? String or 
		something.is_a? TrueClass or 
		something.is_a? FalseClass or
		something.is_a? Numeric
		return something
	elsif something.is_a? Hash
		return something["Ref"] || something["Condition"]
	elsif something.is_a? BooleanValue
		return something.signature
	elsif something.is_a? Resource
		return something.name
	end
end