Class: RiCal::PropertyValue::UtcOffset
- Inherits:
-
RiCal::PropertyValue
- Object
- RiCal::PropertyValue
- RiCal::PropertyValue::UtcOffset
- Defined in:
- lib/ri_cal/property_value/utc_offset.rb
Overview
-
©2009 Rick DeNatale
-
All rights reserved. Refer to the file README.txt for the license
Instance Attribute Summary collapse
-
#hours ⇒ Object
:nodoc:.
-
#minutes ⇒ Object
:nodoc:.
-
#seconds ⇒ Object
:nodoc:.
-
#sign ⇒ Object
:nodoc:.
Attributes inherited from RiCal::PropertyValue
#params, #timezone_finder, #value
Instance Method Summary collapse
- #add_to_date_time_value(date_time_value) ⇒ Object
- #subtract_from_date_time_value(date_time_value) ⇒ Object
- #to_seconds ⇒ Object
- #value=(string) ⇒ Object
Methods inherited from RiCal::PropertyValue
#==, #add_date_times_to, convert, date_or_date_time, #enumerator, #equality_value, #for_parent, from_string, #initialize, #parms_string, #ruby_value, #to_options_hash, #to_ri_cal_property_value, #to_s, #validate_value, #visible_params
Constructor Details
This class inherits a constructor from RiCal::PropertyValue
Instance Attribute Details
#hours ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/ri_cal/property_value/utc_offset.rb', line 7 def hours @hours end |
#minutes ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/ri_cal/property_value/utc_offset.rb', line 7 def minutes @minutes end |
#seconds ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/ri_cal/property_value/utc_offset.rb', line 7 def seconds @seconds end |
#sign ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/ri_cal/property_value/utc_offset.rb', line 7 def sign @sign end |
Instance Method Details
#add_to_date_time_value(date_time_value) ⇒ Object
24 25 26 |
# File 'lib/ri_cal/property_value/utc_offset.rb', line 24 def add_to_date_time_value(date_time_value) date_time_value.advance(:hours => sign * hours, :minutes => sign * minutes, :seconds => sign * minutes) end |
#subtract_from_date_time_value(date_time_value) ⇒ Object
28 29 30 31 |
# File 'lib/ri_cal/property_value/utc_offset.rb', line 28 def subtract_from_date_time_value(date_time_value) signum = -1 * sign date_time_value.advance(:hours => signum * hours, :minutes => signum * minutes, :seconds => signum * minutes) end |
#to_seconds ⇒ Object
20 21 22 |
# File 'lib/ri_cal/property_value/utc_offset.rb', line 20 def to_seconds @sign * ((((hours*60) + minutes) * 60) + seconds) end |
#value=(string) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ri_cal/property_value/utc_offset.rb', line 9 def value=(string) @value = string parse_match = /([+-])(\d\d)(\d\d)(\d\d)?/.match(string) if parse_match @sign = parse_match[1] == "+" ? 1 : -1 @hours = parse_match[2].to_i @minutes = parse_match[3].to_i @seconds = parse_match[4].to_i || 0 end end |