class Campa::Symbol

Represents the name to which a value is bound in a specific {Context}.

Implements the necessary interface to be used with success as key in Hash objects.

Attributes

label[R]

Public Class Methods

new(label) click to toggle source

@param label [String] name to be bound to a value in a given {Context}

# File lib/campa/symbol.rb, line 10
def initialize(label)
  @label = label
end

Public Instance Methods

==(other) click to toggle source

@param other [Symbol] another {Symbol} to be compared @return [Boolean] true if both {#label} are #==

# File lib/campa/symbol.rb, line 16
def ==(other)
  return false if !other.is_a?(self.class)

  label == other.label
end
eql?(other) click to toggle source

@param other [Symbol] another {Symbol} to be compared @return [Boolean] true if both {Symbol} are #==

and both {#hash} are <i>#==</i>
# File lib/campa/symbol.rb, line 25
def eql?(other)
  self == other && hash == other.hash
end
hash() click to toggle source

@return [String] String based on label#hash.

# File lib/campa/symbol.rb, line 30
def hash
  @hash ||= "Campa::Symbol_#{label}".hash
end