Module: TabsTabs::Resolution

Extended by:
Resolution
Includes:
Resolutionable
Included in:
Resolution
Defined in:
lib/tabs_tabs/resolution.rb

Instance Method Summary collapse

Methods included from Resolutionable

included

Instance Method Details

#add(resolution, ts, num) ⇒ Object



28
29
30
# File 'lib/tabs_tabs/resolution.rb', line 28

def add(resolution, ts, num)
  resolution_klass(resolution).add(ts, num)
end

#allObject



36
37
38
# File 'lib/tabs_tabs/resolution.rb', line 36

def all
  @@resolution_classes.keys
end

#deserialize(resolution, str) ⇒ Object



20
21
22
# File 'lib/tabs_tabs/resolution.rb', line 20

def deserialize(resolution, str)
  resolution_klass(resolution).deserialize(str)
end

#expire(resolution, key, timestamp) ⇒ Object



40
41
42
# File 'lib/tabs_tabs/resolution.rb', line 40

def expire(resolution, key, timestamp)
  resolution_klass(resolution).expire(key, timestamp)
end

#from_seconds(resolution, s) ⇒ Object



24
25
26
# File 'lib/tabs_tabs/resolution.rb', line 24

def from_seconds(resolution, s)
  resolution_klass(resolution).from_seconds(s)
end

#normalize(resolution, timestamp) ⇒ Object



32
33
34
# File 'lib/tabs_tabs/resolution.rb', line 32

def normalize(resolution, timestamp)
  resolution_klass(resolution).normalize(timestamp)
end

#register(klass) ⇒ Object



6
7
8
9
# File 'lib/tabs_tabs/resolution.rb', line 6

def register(klass)
  @@resolution_classes ||= {}
  @@resolution_classes[klass.name] = klass
end

#reset_default_resolutionsObject



44
45
46
47
48
49
50
51
52
# File 'lib/tabs_tabs/resolution.rb', line 44

def reset_default_resolutions
  @@resolution_classes = {}
  TabsTabs::Resolution.register(TabsTabs::Resolutions::Minute)
  TabsTabs::Resolution.register(TabsTabs::Resolutions::Hour)
  TabsTabs::Resolution.register(TabsTabs::Resolutions::Day)
  TabsTabs::Resolution.register(TabsTabs::Resolutions::Week)
  TabsTabs::Resolution.register(TabsTabs::Resolutions::Month)
  TabsTabs::Resolution.register(TabsTabs::Resolutions::Year)
end

#serialize(resolution, timestamp) ⇒ Object



16
17
18
# File 'lib/tabs_tabs/resolution.rb', line 16

def serialize(resolution, timestamp)
  resolution_klass(resolution).serialize(timestamp)
end

#unregister(resolutions) ⇒ Object



11
12
13
14
# File 'lib/tabs_tabs/resolution.rb', line 11

def unregister(resolutions)
  resolutions = Array[resolutions].flatten
  resolutions.each{ |res| @@resolution_classes.delete(res) }
end