Class: Spree::Filters::PriceRangePresenter
- Inherits:
-
Object
- Object
- Spree::Filters::PriceRangePresenter
- Defined in:
- app/presenters/spree/filters/price_range_presenter.rb
Instance Attribute Summary collapse
-
#max_price ⇒ Object
readonly
Returns the value of attribute max_price.
-
#min_price ⇒ Object
readonly
Returns the value of attribute min_price.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(min_price:, max_price:) ⇒ PriceRangePresenter
constructor
A new instance of PriceRangePresenter.
- #to_param ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(min_price:, max_price:) ⇒ PriceRangePresenter
Returns a new instance of PriceRangePresenter.
13 14 15 16 |
# File 'app/presenters/spree/filters/price_range_presenter.rb', line 13 def initialize(min_price:, max_price:) @min_price = min_price @max_price = max_price end |
Instance Attribute Details
#max_price ⇒ Object (readonly)
Returns the value of attribute max_price.
18 19 20 |
# File 'app/presenters/spree/filters/price_range_presenter.rb', line 18 def max_price @max_price end |
#min_price ⇒ Object (readonly)
Returns the value of attribute min_price.
18 19 20 |
# File 'app/presenters/spree/filters/price_range_presenter.rb', line 18 def min_price @min_price end |
Class Method Details
.from_param(param, currency:) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'app/presenters/spree/filters/price_range_presenter.rb', line 4 def self.from_param(param, currency:) prices = param.split('-') new( min_price: PricePresenter.new(amount: prices.first, currency: currency), max_price: PricePresenter.new(amount: prices.last, currency: currency) ) end |
Instance Method Details
#to_param ⇒ Object
20 21 22 |
# File 'app/presenters/spree/filters/price_range_presenter.rb', line 20 def to_param "#{min_price.to_i}-#{max_price.to_i}" end |
#to_s ⇒ Object
24 25 26 |
# File 'app/presenters/spree/filters/price_range_presenter.rb', line 24 def to_s "#{min_price} - #{max_price}" end |