Class: OpenEHR::AssumedLibraryTypes::ISO8601Duration
- Inherits:
-
Object
- Object
- OpenEHR::AssumedLibraryTypes::ISO8601Duration
- Includes:
- ISO8601DurationModule
- Defined in:
- lib/open_ehr/assumed_library_types.rb
Constant Summary
Constants included from TimeDefinitions
TimeDefinitions::DAYS_IN_LEAP_YEAR, TimeDefinitions::DAYS_IN_WEEK, TimeDefinitions::DAYS_IN_YEAR, TimeDefinitions::HOURS_IN_DAY, TimeDefinitions::MAX_DAYS_IN_MONTH, TimeDefinitions::MAX_DAYS_IN_YEAR, TimeDefinitions::MINUTES_IN_HOUR, TimeDefinitions::MONTH_IN_YEAR, TimeDefinitions::NOMINAL_DAYS_IN_MONTH, TimeDefinitions::NOMINAL_DAYS_IN_YEAR, TimeDefinitions::SECONDS_IN_MINUTE
Instance Attribute Summary
Attributes included from ISO8601DurationModule
#days, #fractional_second, #hours, #minutes, #months, #seconds, #weeks, #years
Instance Method Summary collapse
-
#initialize(str) ⇒ ISO8601Duration
constructor
A new instance of ISO8601Duration.
Methods included from ISO8601DurationModule
Methods included from TimeDefinitions
valid_day?, valid_hour?, valid_minute?, valid_month?, valid_second?, valid_year?
Constructor Details
#initialize(str) ⇒ ISO8601Duration
Returns a new instance of ISO8601Duration.
676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'lib/open_ehr/assumed_library_types.rb', line 676 def initialize(str) /^P((\d+)[Yy])?((\d+)[Mm])?((\d+)[Ww])?((\d)[dD])?(T((\d+)[Hh])?((\d+)[Mm])?((\d+)(\.\d+)?[Ss])?)?$/ =~ str self.years = $2.to_i self.months = $4.to_i self.weeks = $6.to_i self.days = $8.to_i self.hours = $11.to_i self.minutes = $13.to_i self.seconds = $15.to_i unless $16.nil? self.fractional_second = $16.to_f end end |