Class: TimeZoneProxy
- Inherits:
-
Object
show all
- Defined in:
- lib/clock/time_zone_proxy.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of TimeZoneProxy.
4
5
6
7
|
# File 'lib/clock/time_zone_proxy.rb', line 4
def initialize(target)
raise "Target time zone may not be nil" if target.nil?
@target = target
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
21
22
23
|
# File 'lib/clock/time_zone_proxy.rb', line 21
def method_missing(method, *args)
target.send(method, *args)
end
|
Instance Attribute Details
#target ⇒ Object
Returns the value of attribute target.
2
3
4
|
# File 'lib/clock/time_zone_proxy.rb', line 2
def target
@target
end
|
Instance Method Details
#==(rhs) ⇒ Object
17
18
19
|
# File 'lib/clock/time_zone_proxy.rb', line 17
def ==(rhs)
super(rhs) || self.target == rhs || (rhs.respond_to?(:target) && self.target == rhs.target)
end
|
#now ⇒ Object
9
10
11
|
# File 'lib/clock/time_zone_proxy.rb', line 9
def now
Clock.now.in_time_zone(@target)
end
|
#today ⇒ Object
13
14
15
|
# File 'lib/clock/time_zone_proxy.rb', line 13
def today
Clock.now.in_time_zone(@target).to_date
end
|