module OpenEHR::AssumedLibraryTypes::ISO8601DurationModule
Attributes
days[R]
fractional_second[R]
hours[R]
minutes[R]
months[R]
seconds[R]
weeks[R]
years[R]
Public Instance Methods
as_string()
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 649 def as_string str = 'P' unless @years.nil? str += @years.to_s + 'Y' end unless @months.nil? str += @months.to_s + 'M' end unless @weeks.nil? str += @weeks.to_s + 'W' end unless @days.nil? str += @days.to_s + 'D' end unless @hours.nil? str += 'T' + @hours.to_s + 'H' unless @minutes.nil? str += @minutes.to_s + 'M' unless @seconds.nil? str += @seconds.to_s unless @fractional_second.nil? str += @fractional_second.to_s[1 .. -1] end str += 'S' end end end return str end
days=(days)
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 614 def days=(days) unless days.nil? || days >= 0 raise ArgumentError, 'days must be above zero' end @days = days end
fractional_second=(fractional_second)
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 642 def fractional_second=(fractional_second) unless fractional_second.nil? || (fractional_second >= 0 && fractional_second < 1.0) raise ArgumentError, 'fractional_second must be between 0.0 and 1.0' end @fractional_second = fractional_second end
hours=(hours)
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 621 def hours=(hours) unless hours.nil? || hours >= 0 raise ArgumentError, 'hours must be above zero' end @hours = hours end
minutes=(minutes)
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 628 def minutes=(minutes) unless minutes.nil? || minutes >= 0 raise ArgumentError, 'minutes must be above zero' end @minutes = minutes end
months=(months)
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 600 def months=(months) unless months.nil? || months >= 0 raise ArgumentError, 'months must be above zero' end @months = months end
seconds=(seconds)
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 635 def seconds=(seconds) unless seconds.nil? || seconds >= 0 raise ArgumentError, 'seconds must be above zero' end @seconds = seconds end
to_seconds()
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 679 def to_seconds days = nilthenzero(@years)*TimeDefinitions::DAYS_IN_YEAR + nilthenzero(@months)*TimeDefinitions::DAYS_IN_MONTH + nilthenzero(@weeks)*TimeDefinitions::DAYS_IN_WEEK + nilthenzero(@days) seconds_with_fractional = (((days*TimeDefinitions::HOURS_IN_DAY + nilthenzero(@hours))*TimeDefinitions::MINUTES_IN_HOUR)+nilthenzero(@minutes))*TimeDefinitions::SECONDS_IN_MINUTE + nilthenzero(@seconds) + @fractional_second.to_f return seconds_with_fractional end
weeks=(weeks)
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 607 def weeks=(weeks) unless weeks.nil? || weeks >= 0 raise ArgumentError, 'weeks must be above zero' end @weeks = weeks end
years=(years)
click to toggle source
# File lib/openehr/assumed_library_types.rb, line 593 def years=(years) unless years.nil? || years >= 0 raise ArgumentError, 'years must be above zero' end @years = years end