Class: SymbolOperator
- Inherits:
-
Object
- Object
- SymbolOperator
- Includes:
- Comparable
- Defined in:
- lib/plucky/extensions.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
-
#initialize(field, operator, options = {}) ⇒ SymbolOperator
constructor
A new instance of SymbolOperator.
Constructor Details
#initialize(field, operator, options = {}) ⇒ SymbolOperator
Returns a new instance of SymbolOperator.
7 8 9 |
# File 'lib/plucky/extensions.rb', line 7 def initialize(field, operator, ={}) @field, @operator = field, operator end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
5 6 7 |
# File 'lib/plucky/extensions.rb', line 5 def field @field end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
5 6 7 |
# File 'lib/plucky/extensions.rb', line 5 def operator @operator end |
Instance Method Details
#<=>(other) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/plucky/extensions.rb', line 11 def <=>(other) if field == other.field operator <=> other.operator else field.to_s <=> other.field.to_s end end |
#==(other) ⇒ Object
19 20 21 |
# File 'lib/plucky/extensions.rb', line 19 def ==(other) field == other.field && operator == other.operator end |