Class: PackAPI::Querying::AbstractNumericFilter
- Inherits:
-
DiscoverableFilter
- Object
- AbstractFilter
- DiscoverableFilter
- PackAPI::Querying::AbstractNumericFilter
- Defined in:
- lib/pack_api/querying/abstract_numeric_filter.rb
Instance Attribute Summary collapse
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(operator:, value:) ⇒ AbstractNumericFilter
constructor
A new instance of AbstractNumericFilter.
- #to_h ⇒ Object
Methods inherited from DiscoverableFilter
#filter_name, filter_name, #type
Methods inherited from AbstractFilter
Constructor Details
#initialize(operator:, value:) ⇒ AbstractNumericFilter
Returns a new instance of AbstractNumericFilter.
23 24 25 26 27 |
# File 'lib/pack_api/querying/abstract_numeric_filter.rb', line 23 def initialize(operator:, value:) super() @operator = operator @value = value end |
Instance Attribute Details
#operator ⇒ Object
Returns the value of attribute operator.
5 6 7 |
# File 'lib/pack_api/querying/abstract_numeric_filter.rb', line 5 def operator @operator end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/pack_api/querying/abstract_numeric_filter.rb', line 5 def value @value end |
Class Method Details
.definition ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pack_api/querying/abstract_numeric_filter.rb', line 11 def self.definition(**) operators = [ PackAPI::Types::FilterOption.new(label: 'Greater than', value: '>'), PackAPI::Types::FilterOption.new(label: 'Greater than or equal to', value: '>='), PackAPI::Types::FilterOption.new(label: 'Equal to', value: '='), PackAPI::Types::FilterOption.new(label: 'Less than or equal to', value: '<='), PackAPI::Types::FilterOption.new(label: 'Less than', value: '<') ] PackAPI::Types::NumericFilterDefinition.new(name: filter_name, operators:) end |
.type ⇒ Object
7 8 9 |
# File 'lib/pack_api/querying/abstract_numeric_filter.rb', line 7 def self.type :numeric end |
Instance Method Details
#to_h ⇒ Object
31 32 33 34 35 |
# File 'lib/pack_api/querying/abstract_numeric_filter.rb', line 31 def to_h raise NotImplementedError unless self.class.filter_name { self.class.filter_name => { operator:, value: } } end |