Class: OpenEHR::RM::Support::Identification::VersionTreeID

Inherits:
Object
  • Object
show all
Defined in:
lib/open_ehr/rm/support/identification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ VersionTreeID

Returns a new instance of VersionTreeID.



331
332
333
# File 'lib/open_ehr/rm/support/identification.rb', line 331

def initialize(args = {})
  self.value = args[:value]
end

Instance Attribute Details

#branch_numberObject

Returns the value of attribute branch_number.



329
330
331
# File 'lib/open_ehr/rm/support/identification.rb', line 329

def branch_number
  @branch_number
end

#branch_versionObject

Returns the value of attribute branch_version.



329
330
331
# File 'lib/open_ehr/rm/support/identification.rb', line 329

def branch_version
  @branch_version
end

#trunk_versionObject

Returns the value of attribute trunk_version.



329
330
331
# File 'lib/open_ehr/rm/support/identification.rb', line 329

def trunk_version
  @trunk_version
end

Instance Method Details

#is_branch?Boolean

Returns:

  • (Boolean)


372
373
374
# File 'lib/open_ehr/rm/support/identification.rb', line 372

def is_branch?
  !@branch_version.nil? and !@branch_number.nil?
end

#is_first?Boolean

Returns:

  • (Boolean)


376
377
378
# File 'lib/open_ehr/rm/support/identification.rb', line 376

def is_first?
  trunk_version == '1'
end

#valueObject



343
344
345
346
347
348
# File 'lib/open_ehr/rm/support/identification.rb', line 343

def value
  @value = trunk_version
  @value = @value + '.' + @branch_number unless @branch_number.nil?
  @value = @value + '.' + @branch_version unless @branch_version.nil?
  return @value
end

#value=(value) ⇒ Object

Raises:

  • (ArgumentError)


335
336
337
338
339
340
341
# File 'lib/open_ehr/rm/support/identification.rb', line 335

def value=(value)
  raise ArgumentError, 'value invalid' if value.nil? or value.empty?
  (trunk_version, branch_number, branch_version) = value.split '.'
  self.trunk_version = trunk_version
  self.branch_number = branch_number
  self.branch_version = branch_version
end