Class: Pubid::Iso::Identifiers::Directives

Inherits:
SingleIdentifier show all
Defined in:
lib/pubid/iso/identifiers/directives.rb

Constant Summary collapse

TYPED_STAGES =
[
  ::Pubid::Components::TypedStage.new(
    code: :pubguide,
    stage_code: :published,
    type_code: :dir,
    abbr: ["DIR", "Directives Part", "Directives, Part", "Directives,",
           "Directives"],
    short_abbr: "DIR",
    long_abbr: "Directives, Part",
    name: "Directives",
    harmonized_stages: %w[60.00 60.60],
  ),
].freeze

Constants inherited from Pubid::Iso::Identifier

Pubid::Iso::Identifier::ISO_TYPE_MAP

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pubid::Iso::Identifier

build_type_map, parse

Methods inherited from Pubid::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_supplement_s, #urn_supplement_type, #urn_type_code

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.typeObject



24
25
26
# File 'lib/pubid/iso/identifiers/directives.rb', line 24

def self.type
  { key: :dir, title: "Directives", short: "DIR" }
end

Instance Method Details

#to_s(**opts) ⇒ Object



28
29
30
31
32
# File 'lib/pubid/iso/identifiers/directives.rb', line 28

def to_s(**opts)
  context = build_rendering_context(nil, format: :human, **opts)
  Pubid::Renderers::DirectivesRenderer.new(self).render(context:,
                                                        **opts.slice(:with_edition))
end

#to_urnObject

Directives use a different URN scheme: urn:iso:doc instead of urn:iso:std Format: urn:iso:doc:publisher[:subgroup_number]:dir[:part][:year]



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/pubid/iso/identifiers/directives.rb', line 36

def to_urn
  parts = ["urn", "iso", "doc"]

  copubs = copublishers || []
  parts << ([publisher] + copubs).map(&:body).map(&:downcase).join("-")

  if subgroup
    subgroup_parts = subgroup.value.split
    parts << subgroup_parts[0].downcase if subgroup_parts[0]
    parts << subgroup_parts[1] if subgroup_parts[1]
  end

  parts << "dir"

  parts << number.value if number
  parts << part.value.downcase if part
  parts << date.year if date

  parts.join(":")
end