class Chartable::PeriodQuery

Constants

PERIODS

Public Class Methods

build(period) click to toggle source

It returns the proper query object for selected period. If given period is not supported it raises `Chartable::Errors::InvalidPeriodError` error

@return [Class]

# 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