Class: KBS::DSL::Variable
- Inherits:
-
Object
- Object
- KBS::DSL::Variable
- Defined in:
- lib/kbs/dsl/variable.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name) ⇒ Variable
constructor
A new instance of Variable.
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(name) ⇒ Variable
Returns a new instance of Variable.
8 9 10 11 |
# File 'lib/kbs/dsl/variable.rb', line 8 def initialize(name) name_str = name.to_s @name = name_str.end_with?('?') ? name_str.to_sym : "#{name_str}?".to_sym end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/kbs/dsl/variable.rb', line 6 def name @name end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 24 |
# File 'lib/kbs/dsl/variable.rb', line 21 def ==(other) return false unless other.is_a?(Variable) @name == other.name end |
#eql?(other) ⇒ Boolean
26 27 28 |
# File 'lib/kbs/dsl/variable.rb', line 26 def eql?(other) self == other end |
#hash ⇒ Object
30 31 32 |
# File 'lib/kbs/dsl/variable.rb', line 30 def hash @name.hash end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/kbs/dsl/variable.rb', line 17 def to_s @name.to_s end |
#to_sym ⇒ Object
13 14 15 |
# File 'lib/kbs/dsl/variable.rb', line 13 def to_sym @name end |