Class: SymbolOperator
- Includes:
- Comparable
- Defined in:
- lib/plucky/extensions/symbol.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(field, operator, options = {}) ⇒ SymbolOperator
constructor
A new instance of SymbolOperator.
Constructor Details
#initialize(field, operator, options = {}) ⇒ SymbolOperator
Returns a new instance of SymbolOperator.
65 66 67 |
# File 'lib/plucky/extensions/symbol.rb', line 65 def initialize(field, operator, ={}) @field, @operator = field, operator end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
63 64 65 |
# File 'lib/plucky/extensions/symbol.rb', line 63 def field @field end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
63 64 65 |
# File 'lib/plucky/extensions/symbol.rb', line 63 def operator @operator end |
Instance Method Details
#<=>(other) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/plucky/extensions/symbol.rb', line 69 def <=>(other) if field == other.field operator <=> other.operator else field.to_s <=> other.field.to_s end end |
#==(other) ⇒ Object
85 86 87 |
# File 'lib/plucky/extensions/symbol.rb', line 85 def ==(other) other.class == self.class && field == other.field && operator == other.operator end |
#eql?(other) ⇒ Boolean
81 82 83 |
# File 'lib/plucky/extensions/symbol.rb', line 81 def eql?(other) self == other end |
#hash ⇒ Object
77 78 79 |
# File 'lib/plucky/extensions/symbol.rb', line 77 def hash field.hash + operator.hash end |