Class: OpenEHR::AssumedLibraryTypes::ISO8601Timezone
- Inherits:
-
Object
- Object
- OpenEHR::AssumedLibraryTypes::ISO8601Timezone
- Defined in:
- lib/open_ehr/assumed_library_types.rb
Instance Attribute Summary collapse
-
#hour ⇒ Object
Returns the value of attribute hour.
-
#minute ⇒ Object
Returns the value of attribute minute.
-
#sign ⇒ Object
Returns the value of attribute sign.
Instance Method Summary collapse
- #as_string ⇒ Object
-
#initialize(string) ⇒ ISO8601Timezone
constructor
A new instance of ISO8601Timezone.
- #is_gmt? ⇒ Boolean
Constructor Details
#initialize(string) ⇒ ISO8601Timezone
Returns a new instance of ISO8601Timezone.
494 495 496 497 498 499 500 501 502 503 |
# File 'lib/open_ehr/assumed_library_types.rb', line 494 def initialize(string) unless /(Z|(([+-])(\d{2}):?(\d{2})))/ =~ string raise ArgumentError, 'invaild format' end if $1 == 'Z' @sign, @hour, @minute = +1, 0, 0 else @sign, @hour, @minute = ($3+'1').to_i, $4.to_i , $5.to_i end end |
Instance Attribute Details
#hour ⇒ Object
Returns the value of attribute hour.
492 493 494 |
# File 'lib/open_ehr/assumed_library_types.rb', line 492 def hour @hour end |
#minute ⇒ Object
Returns the value of attribute minute.
492 493 494 |
# File 'lib/open_ehr/assumed_library_types.rb', line 492 def minute @minute end |
#sign ⇒ Object
Returns the value of attribute sign.
492 493 494 |
# File 'lib/open_ehr/assumed_library_types.rb', line 492 def sign @sign end |
Instance Method Details
#as_string ⇒ Object
509 510 511 512 513 514 515 516 |
# File 'lib/open_ehr/assumed_library_types.rb', line 509 def as_string if @sign == +1 s = "+" elsif @sign == -1 s = "-" end sprintf("%s%02d%02d", s, @hour, @minute) end |
#is_gmt? ⇒ Boolean
505 506 507 |
# File 'lib/open_ehr/assumed_library_types.rb', line 505 def is_gmt? @sign == +1 and @hour == 0 and @minute == 0 end |