Module: TabsTabs::Resolutions::Minute
- Extended by:
- Minute
- Includes:
- TabsTabs::Resolutionable
- Included in:
- Minute
- Defined in:
- lib/tabs_tabs/resolutions/minute.rb
Constant Summary collapse
- PATTERN =
"%Y-%m-%d-%H-%M"
Instance Method Summary collapse
- #add(ts, num) ⇒ Object
- #deserialize(str) ⇒ Object
- #from_seconds(s) ⇒ Object
- #name ⇒ Object
- #normalize(ts) ⇒ Object
- #serialize(timestamp) ⇒ Object
- #to_seconds ⇒ Object
Methods included from TabsTabs::Resolutionable
Instance Method Details
#add(ts, num) ⇒ Object
30 31 32 |
# File 'lib/tabs_tabs/resolutions/minute.rb', line 30 def add(ts, num) ts + num.minutes end |
#deserialize(str) ⇒ Object
17 18 19 20 |
# File 'lib/tabs_tabs/resolutions/minute.rb', line 17 def deserialize(str) dt = DateTime.strptime(str, PATTERN) self.normalize(dt) end |
#from_seconds(s) ⇒ Object
22 23 24 |
# File 'lib/tabs_tabs/resolutions/minute.rb', line 22 def from_seconds(s) s / 1.minute end |
#name ⇒ Object
9 10 11 |
# File 'lib/tabs_tabs/resolutions/minute.rb', line 9 def name :minute end |
#normalize(ts) ⇒ Object
34 35 36 |
# File 'lib/tabs_tabs/resolutions/minute.rb', line 34 def normalize(ts) Time.utc(ts.year, ts.month, ts.day, ts.hour, ts.min) end |
#serialize(timestamp) ⇒ Object
13 14 15 |
# File 'lib/tabs_tabs/resolutions/minute.rb', line 13 def serialize() .strftime(PATTERN) end |
#to_seconds ⇒ Object
26 27 28 |
# File 'lib/tabs_tabs/resolutions/minute.rb', line 26 def to_seconds 1.minute end |