Class: Spree::Report::TimedObservation
- Inherits:
-
Observation
- Object
- Observation
- Spree::Report::TimedObservation
- Extended by:
- Forwardable
- Defined in:
- app/reports/spree/report/timed_observation.rb
Direct Known Subclasses
PaymentMethodTransactionsConversionRateReport::Result::Observation, PaymentMethodTransactionsReport::Result::Observation, PromotionalCostReport::Result::Observation, SalesPerformanceReport::Result::Observation, SalesTaxReport::Result::Observation, ShippingCostReport::Result::Observation, UserPoolReport::Result::Observation
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#hour ⇒ Object
Returns the value of attribute hour.
-
#reportable_keys ⇒ Object
Returns the value of attribute reportable_keys.
Instance Method Summary collapse
- #day_name ⇒ Object
- #describes?(result, time_scale) ⇒ Boolean
- #hour_name ⇒ Object
-
#initialize ⇒ TimedObservation
constructor
A new instance of TimedObservation.
- #month_name ⇒ Object
- #to_h ⇒ Object
Methods inherited from Observation
build_from_hash, build_from_list, observation_fields
Constructor Details
#initialize ⇒ TimedObservation
Returns a new instance of TimedObservation.
9 10 11 12 |
# File 'app/reports/spree/report/timed_observation.rb', line 9 def initialize super self.hour = 0 end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
5 6 7 |
# File 'app/reports/spree/report/timed_observation.rb', line 5 def date @date end |
#hour ⇒ Object
Returns the value of attribute hour.
5 6 7 |
# File 'app/reports/spree/report/timed_observation.rb', line 5 def hour @hour end |
#reportable_keys ⇒ Object
Returns the value of attribute reportable_keys.
5 6 7 |
# File 'app/reports/spree/report/timed_observation.rb', line 5 def reportable_keys @reportable_keys end |
Instance Method Details
#day_name ⇒ Object
39 40 41 |
# File 'app/reports/spree/report/timed_observation.rb', line 39 def day_name "#{ day } #{ month_name }" end |
#describes?(result, time_scale) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/reports/spree/report/timed_observation.rb', line 14 def describes?(result, time_scale) case time_scale when :hourly result['hour'] == hour && result['day'] == day when :daily result['day'] == day && result['month'] == month when :monthly result['month'] == month && result['year'] == year when :yearly result['year'] == year end end |
#hour_name ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/reports/spree/report/timed_observation.rb', line 31 def hour_name if hour == 23 return "23:00 - 00:00" else return "#{ hour }:00 - #{ hour + 1 }:00" end end |
#month_name ⇒ Object
27 28 29 |
# File 'app/reports/spree/report/timed_observation.rb', line 27 def month_name Date::MONTHNAMES[month] end |
#to_h ⇒ Object
43 44 45 |
# File 'app/reports/spree/report/timed_observation.rb', line 43 def to_h super.merge({day_name: day_name, month_name: month_name, year: year, hour_name: hour_name}) end |