Class: Icalendar::Values::UtcOffset
- Inherits:
-
Icalendar::Value
- Object
- SimpleDelegator
- Icalendar::Value
- Icalendar::Values::UtcOffset
- Defined in:
- lib/icalendar/values/utc_offset.rb
Constant Summary
Constants inherited from Icalendar::Value
Icalendar::Value::VALUE_TYPE_GSUB_REGEX_1, Icalendar::Value::VALUE_TYPE_GSUB_REGEX_2
Instance Attribute Summary
Attributes inherited from Icalendar::Value
Instance Method Summary collapse
- #behind? ⇒ Boolean
-
#initialize(value, params = {}) ⇒ UtcOffset
constructor
A new instance of UtcOffset.
- #to_s ⇒ Object
- #value_ical ⇒ Object
Methods inherited from Icalendar::Value
#==, #ical_param, #params_ical, #to_ical, #value, value_type, #value_type
Constructor Details
#initialize(value, params = {}) ⇒ UtcOffset
Returns a new instance of UtcOffset.
8 9 10 11 12 13 14 15 |
# File 'lib/icalendar/values/utc_offset.rb', line 8 def initialize(value, params = {}) if value.is_a? Icalendar::Values::UtcOffset value = value.value else value = OpenStruct.new parse_fields(value) end super value, params end |
Instance Method Details
#behind? ⇒ Boolean
17 18 19 20 |
# File 'lib/icalendar/values/utc_offset.rb', line 17 def behind? return false if zero_offset? value.behind end |
#to_s ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/icalendar/values/utc_offset.rb', line 26 def to_s str = "#{behind? ? '-' : '+'}#{'%02d' % hours}:#{'%02d' % minutes}" if seconds > 0 "#{str}:#{'%02d' % seconds}" else str end end |
#value_ical ⇒ Object
22 23 24 |
# File 'lib/icalendar/values/utc_offset.rb', line 22 def value_ical "#{behind? ? '-' : '+'}#{'%02d' % hours}#{'%02d' % minutes}#{'%02d' % seconds if seconds > 0}" end |