Class: Campa::Symbol

Inherits:
Object
  • Object
show all
Defined in:
lib/campa/symbol.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label) ⇒ Symbol

Returns a new instance of Symbol.



5
6
7
# File 'lib/campa/symbol.rb', line 5

def initialize(label)
  @label = label
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



3
4
5
# File 'lib/campa/symbol.rb', line 3

def label
  @label
end

Instance Method Details

#==(other) ⇒ Object



9
10
11
12
13
# File 'lib/campa/symbol.rb', line 9

def ==(other)
  return false if !other.is_a?(self.class)

  label == other.label
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/campa/symbol.rb', line 15

def eql?(other)
  self == other && hash == other.hash
end

#hashObject



19
20
21
# File 'lib/campa/symbol.rb', line 19

def hash
  @hash ||= "Campa::Symbol_#{label}".hash
end