Class: Pubid::Etsi::Identifier

Inherits:
Identifier
  • Object
show all
Defined in:
lib/pubid/etsi/identifiers/base.rb

Overview

Base class for all ETSI identifiers. Canonical name Pubid::Etsi::Identifier (Identifiers::Base is a back-compat alias); every concrete ETSI identifier descends from it.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Identifier

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

Constructor Details

This class inherits a constructor from Pubid::Identifier

Class Method Details

.parse(identifier) ⇒ Object



9
10
11
12
13
14
# File 'lib/pubid/etsi/identifiers/base.rb', line 9

def self.parse(identifier)
  parsed = Parser.parse(identifier)
  Builder.build(parsed)
rescue Parslet::ParseFailed => e
  raise "Failed to parse ETSI identifier '#{identifier}': #{e.message}"
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/pubid/etsi/identifiers/base.rb', line 26

def ==(other)
  return false unless other.is_a?(Pubid::Etsi::Identifier)

  type == other.type &&
    code == other.code &&
    version == other.version &&
    date == other.date
end