Class: Priora::Priority
- Inherits:
-
Object
- Object
- Priora::Priority
- Defined in:
- lib/priora/priority.rb
Constant Summary collapse
- DIRECTION_DESC =
:desc
- DIRECTION_ASC =
:asc
- DIRECTIONAL_METHODS =
{ DIRECTION_DESC => :+, DIRECTION_ASC => :- }.freeze
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
Instance Method Summary collapse
- #comparable_value_from(object) ⇒ Object
-
#initialize(attribute:, direction: DIRECTION_DESC) ⇒ Priority
constructor
A new instance of Priority.
Constructor Details
#initialize(attribute:, direction: DIRECTION_DESC) ⇒ Priority
Returns a new instance of Priority.
13 14 15 16 |
# File 'lib/priora/priority.rb', line 13 def initialize(attribute:, direction: DIRECTION_DESC) @attribute = attribute @direction = direction end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
11 12 13 |
# File 'lib/priora/priority.rb', line 11 def attribute @attribute end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
11 12 13 |
# File 'lib/priora/priority.rb', line 11 def direction @direction end |
Instance Method Details
#comparable_value_from(object) ⇒ Object
18 19 20 21 22 |
# File 'lib/priora/priority.rb', line 18 def comparable_value_from(object) raw_value = object.send(@attribute) numeric_value = numeric_value_from(raw_value) directional_value_from(numeric_value) end |