Class: Pubid::CenCenelec::SupplementIdentifier

Inherits:
Identifiers::Base show all
Defined in:
lib/pubid/cen_cenelec/supplement_identifier.rb

Instance Method Summary collapse

Methods inherited from Identifiers::Base

#==, #to_s

Methods inherited from Identifier

#base_identifier, #eql?, #exclude, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, #render, #resolve_urn_generator, #root, #to_mr_string, #to_s, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code

Constructor Details

This class inherits a constructor from Pubid::Identifier

Instance Method Details

#<=>(other) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/pubid/cen_cenelec/supplement_identifier.rb', line 24

def <=>(other)
  return nil unless other.is_a?(SupplementIdentifier)

  # Compare base identifiers first
  base_cmp = base_identifier <=> other.base_identifier
  return base_cmp unless base_cmp.zero?

  # Then compare numbers
  num_cmp = (number || Components::Code.new(value: "0")).to_s <=> (other.number || Components::Code.new(value: "0")).to_s
  return num_cmp unless num_cmp.zero?

  # Finally compare dates
  if date && other.date
    date.to_s <=> other.date.to_s
  elsif date
    1
  elsif other.date
    -1
  else
    0
  end
end

#copublishersObject



20
21
22
# File 'lib/pubid/cen_cenelec/supplement_identifier.rb', line 20

def copublishers
  base_identifier&.copublishers
end

#publisherObject

Delegate methods to base_identifier for convenient access



16
17
18
# File 'lib/pubid/cen_cenelec/supplement_identifier.rb', line 16

def publisher
  base_identifier&.publisher
end