Class: Formatter::Date::TimeOrDateTime
- Inherits:
-
TZInfo::TimeOrDateTime
- Object
- TZInfo::TimeOrDateTime
- Formatter::Date::TimeOrDateTime
- Defined in:
- lib/formatter/date.rb
Overview
Wrapper class around TZInfo::TimeOrDateTime that only accepts Time or DateTime.
Instance Method Summary collapse
-
#initialize(object) ⇒ TimeOrDateTime
constructor
A new instance of TimeOrDateTime.
Constructor Details
#initialize(object) ⇒ TimeOrDateTime
Returns a new instance of TimeOrDateTime.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/formatter/date.rb', line 12 def initialize(object) case object when Time object = object.utc when DateTime object = object.new_offset Rational(0, 24) else fail ArgumentError, "invalid Time or DateTime: #{object.inspect}" end super TZInfo::TimeOrDateTime.wrap(object) end |