Class: KBS::DSL::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/kbs/dsl/variable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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

Returns:

  • (Boolean)


26
27
28
# File 'lib/kbs/dsl/variable.rb', line 26

def eql?(other)
  self == other
end

#hashObject



30
31
32
# File 'lib/kbs/dsl/variable.rb', line 30

def hash
  @name.hash
end

#to_sObject



17
18
19
# File 'lib/kbs/dsl/variable.rb', line 17

def to_s
  @name.to_s
end

#to_symObject



13
14
15
# File 'lib/kbs/dsl/variable.rb', line 13

def to_sym
  @name
end