Class: Trifle::Stats::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/trifle/stats/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
# File 'lib/trifle/stats/configuration.rb', line 11

def initialize
  @ranges = %i[minute hour day week month quarter year]
  @beginning_of_week = :monday
  @time_zone = 'GMT'
  @designator = nil
end

Instance Attribute Details

#beginning_of_weekObject

Returns the value of attribute beginning_of_week.



9
10
11
# File 'lib/trifle/stats/configuration.rb', line 9

def beginning_of_week
  @beginning_of_week
end

#designatorObject

Returns the value of attribute designator.



9
10
11
# File 'lib/trifle/stats/configuration.rb', line 9

def designator
  @designator
end

#driverObject

Raises:



32
33
34
35
36
# File 'lib/trifle/stats/configuration.rb', line 32

def driver
  raise DriverNotFound if @driver.nil?

  @driver
end

#time_zoneObject

Returns the value of attribute time_zone.



9
10
11
# File 'lib/trifle/stats/configuration.rb', line 9

def time_zone
  @time_zone
end

#track_rangesObject

Returns the value of attribute track_ranges.



9
10
11
# File 'lib/trifle/stats/configuration.rb', line 9

def track_ranges
  @track_ranges
end

Instance Method Details

#rangesObject



26
27
28
29
30
# File 'lib/trifle/stats/configuration.rb', line 26

def ranges
  return @ranges if blank?(track_ranges)

  @ranges & track_ranges
end

#tzObject



18
19
20
21
22
23
24
# File 'lib/trifle/stats/configuration.rb', line 18

def tz
  TZInfo::Timezone.get(@time_zone)
rescue TZInfo::InvalidTimezoneIdentifier => e
  puts "Trifle: #{e} - #{time_zone}; Defaulting to GMT."

  TZInfo::Timezone.get('GMT')
end