Class: Barometer::Data::ZoneOffset
- Inherits:
-
Object
- Object
- Barometer::Data::ZoneOffset
- Defined in:
- lib/barometer/data/zone.rb
Class Method Summary collapse
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(zone, time_class = ::Time) ⇒ ZoneOffset
constructor
A new instance of ZoneOffset.
- #local_to_utc(local_time) ⇒ Object
- #now ⇒ Object
- #offset ⇒ Object
- #to_s ⇒ Object
- #utc_to_local(utc_time) ⇒ Object
Constructor Details
#initialize(zone, time_class = ::Time) ⇒ ZoneOffset
Returns a new instance of ZoneOffset.
66 67 68 69 |
# File 'lib/barometer/data/zone.rb', line 66 def initialize(zone, time_class=::Time) @zone = zone @time_class = time_class end |
Class Method Details
.detect?(zone) ⇒ Boolean
62 63 64 |
# File 'lib/barometer/data/zone.rb', line 62 def self.detect?(zone) zone.respond_to?(:abs) && zone.abs <= 14 end |
Instance Method Details
#code ⇒ Object
71 72 |
# File 'lib/barometer/data/zone.rb', line 71 def code end |
#local_to_utc(local_time) ⇒ Object
86 87 88 |
# File 'lib/barometer/data/zone.rb', line 86 def local_to_utc(local_time) local_time - offset end |
#now ⇒ Object
78 79 80 |
# File 'lib/barometer/data/zone.rb', line 78 def now time_class.now.utc + offset end |
#offset ⇒ Object
74 75 76 |
# File 'lib/barometer/data/zone.rb', line 74 def offset zone.to_f * 60 * 60 end |
#to_s ⇒ Object
82 83 84 |
# File 'lib/barometer/data/zone.rb', line 82 def to_s zone.to_s end |
#utc_to_local(utc_time) ⇒ Object
90 91 92 |
# File 'lib/barometer/data/zone.rb', line 90 def utc_to_local(utc_time) utc_time + offset end |