Class: PopCap::Formatters::Duration

Inherits:
Formatter
  • Object
show all
Defined in:
lib/pop_cap/formatters/duration.rb

Overview

Public: This will format a duration tag as strftime.

time - Provide a string, float, or integer.

Instance Attribute Summary

Attributes inherited from Formatter

#options, #value

Instance Method Summary collapse

Methods inherited from Formatter

format, #initialize, subclasses, subclasses_demodulized

Constructor Details

This class inherits a constructor from PopCap::Formatters::Formatter

Instance Method Details

#formatObject

Public: This will format a duration tag as strftime. It will raise a warning if the time is greater than 24 hours. Leading zeroes & colons are removed.

Examples

dur = Duration.new(420)
dur.format
# => '7:00'


18
19
20
21
22
# File 'lib/pop_cap/formatters/duration.rb', line 18

def format
  return unless value.to_i > 0
  return warning_message if over_twenty_four_hours?
  human_readable_time
end