Class: MTK::Lang::Variable
- Inherits:
-
Object
- Object
- MTK::Lang::Variable
- Defined in:
- lib/mtk/lang/variable.rb
Overview
A placeholder element for a variable value, for use within a Patterns::Pattern such as a Patterns::ForEach pattern. Will be evaluated to an actual value by the Pattern or Sequencer
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#implicit? ⇒ Boolean
True when this variable has no specific value and references the implicit variable stack (such as in a Patterns::ForEach).
-
#initialize(name, value = nil) ⇒ Variable
constructor
A new instance of Variable.
- #to_s ⇒ Object
Constructor Details
#initialize(name, value = nil) ⇒ Variable
Returns a new instance of Variable.
12 13 14 15 16 |
# File 'lib/mtk/lang/variable.rb', line 12 def initialize name, value=nil @name = name @value = value @implicit = !!(name =~ /^\$+$/) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/mtk/lang/variable.rb', line 8 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
10 11 12 |
# File 'lib/mtk/lang/variable.rb', line 10 def value @value end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 |
# File 'lib/mtk/lang/variable.rb', line 23 def == other other.is_a? self.class and other.name == self.name end |
#implicit? ⇒ Boolean
Returns true when this variable has no specific value and references the implicit variable stack (such as in a Patterns::ForEach).
19 20 21 |
# File 'lib/mtk/lang/variable.rb', line 19 def implicit? @implicit end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/mtk/lang/variable.rb', line 27 def to_s "#{self.class}<#{name}#{'='+value.to_s if value}>" end |