Class: SymbolOperator

Inherits:
Object show all
Includes:
Comparable
Defined in:
lib/mark_mapper/extensions/symbol.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, operator) ⇒ SymbolOperator

Returns a new instance of SymbolOperator.


55
56
57
# File 'lib/mark_mapper/extensions/symbol.rb', line 55

def initialize(field, operator)
  @field, @operator = field, operator
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field


53
54
55
# File 'lib/mark_mapper/extensions/symbol.rb', line 53

def field
  @field
end

#operatorObject (readonly)

Returns the value of attribute operator


53
54
55
# File 'lib/mark_mapper/extensions/symbol.rb', line 53

def operator
  @operator
end

Instance Method Details

#<=>(other) ⇒ Object


59
60
61
62
63
64
65
# File 'lib/mark_mapper/extensions/symbol.rb', line 59

def <=>(other)
  if field == other.field
    operator <=> other.operator
  else
    field.to_s <=> other.field.to_s
  end
end

#==(other) ⇒ Object


75
76
77
# File 'lib/mark_mapper/extensions/symbol.rb', line 75

def ==(other)
  other.class == self.class && field == other.field && operator == other.operator
end

#eql?(other) ⇒ Boolean

Returns:


71
72
73
# File 'lib/mark_mapper/extensions/symbol.rb', line 71

def eql?(other)
  self == other
end

#hashObject


67
68
69
# File 'lib/mark_mapper/extensions/symbol.rb', line 67

def hash
  field.hash + operator.hash
end