Class: Repor::Dimensions::TimeDimension::Bin

Inherits:
BinDimension::Bin show all
Defined in:
lib/repor/dimensions/time_dimension.rb

Instance Method Summary collapse

Methods inherited from BinDimension::Bin

#==, #[], #as_json, #bin_text, #cast_bin_text, #contains_sql, from_hash, from_sql, #has_key?, #hash, #initialize, #inspect, #max, #min, #parses?, #quote, #row_sql, #valid?, #values_at

Constructor Details

This class inherits a constructor from Repor::Dimensions::BinDimension::Bin

Instance Method Details

#cast(value) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/repor/dimensions/time_dimension.rb', line 79

def cast(value)
  case Repor.database_type
  when :postgres
    "CAST(#{super} AS timestamp with time zone)"
  when :sqlite
    "DATETIME(#{super})"
  else
    "CAST(#{super} AS DATETIME)"
  end
end

#parse(value) ⇒ Object



75
76
77
# File 'lib/repor/dimensions/time_dimension.rb', line 75

def parse(value)
  Time.zone.parse(value.to_s.gsub('"', ''))
end