Class: Pubid::Sae::Identifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Pubid::Sae::Identifier
- Defined in:
- lib/pubid/sae/identifiers/base.rb
Overview
Base SAE Identifier. Canonical name Pubid::Sae::Identifier. SAE has a single identifier class that IS the document type, so this class is both the base and the only concrete type. Handles all SAE document types (AMS, AIR, ARP, AS, MA).
Class Method Summary collapse
Instance Method Summary collapse
-
#mr_type ⇒ Object
SAE encodes the document class (AS, ARP, AMS, AIR, J, …) in
type.abbr, not intyped_stage.type_code, so the generic mr_type returns nil. - #year ⇒ Object
Methods inherited from Identifier
apply_mappings, #base, #base_document, concrete_class_for, #dated_version_of?, #draft_of?, #drop_supplements, #edition_of?, #eql?, #exclude, from_hash, #has_supplement?, #hash, #includes?, #initialize, #matches?, #mr_all_parts, #mr_edition, #mr_languages, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_subpart, #mr_supplement_suffix, #mr_year, #new_edition_of?, polymorphic_name, polymorphic_type_map, #related_to?, #render, #resolve_urn_generator, #root, #sibling_of?, #supplement_of?, #to_hash, #to_mr_string, #to_s, #to_slug, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code
Constructor Details
This class inherits a constructor from Pubid::Identifier
Class Method Details
.parse(input) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/pubid/sae/identifiers/base.rb', line 9 def self.parse(input) parsed = Parser.parse(input) Builder.build(parsed) rescue Parslet::ParseFailed => e raise "Failed to parse SAE identifier: #{input}\n#{e.}" end |
.type ⇒ Object
21 22 23 |
# File 'lib/pubid/sae/identifiers/base.rb', line 21 def self.type { key: :base, web: :standard, title: "Standard", short: "SAE" } end |
Instance Method Details
#mr_type ⇒ Object
SAE encodes the document class (AS, ARP, AMS, AIR, J, …) in type.abbr,
not in typed_stage.type_code, so the generic mr_type returns nil.
Losslessness requires the type letter to appear in MR — without it,
SAE J300 and SAE AS300 would collide on SAE.300.<year>.
Lowercased to match the all-lowercase MR convention (issue #142).
34 35 36 |
# File 'lib/pubid/sae/identifiers/base.rb', line 34 def mr_type type&.abbr&.to_s&.downcase end |
#year ⇒ Object
25 26 27 |
# File 'lib/pubid/sae/identifiers/base.rb', line 25 def year date&.year end |