Module: OpenEHR::AssumedLibraryTypes::ISO8601DateModule

Included in:
ISO8601Date, ISO8601DateTimeModule
Defined in:
lib/open_ehr/assumed_library_types.rb

Overview

end of TimeDefinitions

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dayObject

Returns the value of attribute day.



137
138
139
# File 'lib/open_ehr/assumed_library_types.rb', line 137

def day
  @day
end

#monthObject

Returns the value of attribute month.



137
138
139
# File 'lib/open_ehr/assumed_library_types.rb', line 137

def month
  @month
end

#yearObject

Returns the value of attribute year.



137
138
139
# File 'lib/open_ehr/assumed_library_types.rb', line 137

def year
  @year
end

Instance Method Details

#as_stringObject



157
158
159
160
161
162
163
164
165
# File 'lib/open_ehr/assumed_library_types.rb', line 157

def as_string
  if (!@year.nil? and !@month.nil? and !@day.nil?)
    Date.new(@year, @month, @day).to_s
  elsif (!@year.nil? and !@month.nil? and @day.nil?)
    Date.new(@year, @month).to_s[0,7]
  elsif (!@year.nil? and @month.nil? and @day.nil?)
    Date.new(@year).to_s[0,4]
  end          
end

#day_unknown?Boolean

Returns:

  • (Boolean)


178
179
180
# File 'lib/open_ehr/assumed_library_types.rb', line 178

def day_unknown?
  @day.nil?
end

#is_extended?Boolean

Returns:

  • (Boolean)


182
183
184
# File 'lib/open_ehr/assumed_library_types.rb', line 182

def is_extended?
  true
end

#is_partial?Boolean

Returns:

  • (Boolean)


186
187
188
# File 'lib/open_ehr/assumed_library_types.rb', line 186

def is_partial?
  month_unknown? or day_unknown?
end

#month_unknown?Boolean

Returns:

  • (Boolean)


174
175
176
# File 'lib/open_ehr/assumed_library_types.rb', line 174

def month_unknown?
  @month.nil?
end

#to_daysObject



167
168
169
170
171
172
# File 'lib/open_ehr/assumed_library_types.rb', line 167

def to_days
  days = nilthenzero(@year)*TimeDefinitions::NOMINAL_DAYS_IN_YEAR +
    nilthenzero(@month)*TimeDefinitions::NOMINAL_DAYS_IN_MONTH +
    nilthenzero(@day)
  return days
end