Class: Chartable::PeriodQuery
- Inherits:
-
Object
- Object
- Chartable::PeriodQuery
- Defined in:
- lib/chartable/period_query.rb
Constant Summary collapse
- PERIODS =
{ daily: Chartable::Queries::Daily, weekly: Chartable::Queries::Weekly, quarterly: Chartable::Queries::Quarterly, yearly: Chartable::Queries::Yearly, monthly: Chartable::Queries::Monthly }
Class Method Summary collapse
-
.build(period) ⇒ Class
It returns the proper query object for selected period.
Class Method Details
.build(period) ⇒ Class
It returns the proper query object for selected period. If given period is not supported it raises ‘Chartable::Errors::InvalidPeriodError` error
15 16 17 18 19 20 21 |
# File 'lib/chartable/period_query.rb', line 15 def self.build(period) period_class = PERIODS[period] raise(Chartable::Errors::InvalidPeriodError, "#{period} is not valid, valid one are: #{PERIODS.keys.join(', ')}") if period_class.nil? period_class end |