Class: Pubid::Bsi::SingleIdentifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Pubid::Bsi::SingleIdentifier
- Includes:
- Identifier
- Defined in:
- lib/pubid/bsi/single_identifier.rb
Direct Known Subclasses
Identifiers::AddendumDocument, Identifiers::AerospaceStandard, Identifiers::Amendment, Identifiers::BritishIndustrialPractice, Identifiers::BritishStandard, Identifiers::BundledIdentifier, Identifiers::CommitteeDocument, Identifiers::ConsolidatedIdentifier, Identifiers::Corrigendum, Identifiers::DetailedSpecification, Identifiers::Disc, Identifiers::DraftDocument, Identifiers::ElectronicBook, Identifiers::ExpertCommentary, Identifiers::ExplanatorySupplement, Identifiers::Flex, Identifiers::Handbook, Identifiers::Index, Identifiers::Method, Identifiers::NationalAnnex, Identifiers::PracticeGuide, Identifiers::PubliclyAvailableSpecification, Identifiers::PublishedDocument, Identifiers::Section, Identifiers::Set, Identifiers::StandaloneAmendment, Identifiers::SupplementDocument, Identifiers::SupplementaryIndex, Identifiers::TechnicalSpecification, Identifiers::TestMethod, Identifiers::ValueAddedPublication
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#publisher ⇒ String
Generate URN for this identifier.
- #to_s(lang: :en, lang_single: false) ⇒ Object
Methods included from Identifier
Methods included from IdentifierFacade
#from_hash, #polymorphic_type_map
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_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year
Constructor Details
This class inherits a constructor from Pubid::Identifier
Instance Method Details
#<=>(other) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pubid/bsi/single_identifier.rb', line 41 def <=>(other) return nil unless other.is_a?(SingleIdentifier) # Compare by number first num_cmp = number.to_s <=> other.number.to_s return num_cmp unless num_cmp.zero? # Then by part part_cmp = (part || Components::Code.new(value: "0")).to_s <=> (other.part || Components::Code.new(value: "0")).to_s return part_cmp unless part_cmp.zero? # Then by date if date && other.date date.to_s <=> other.date.to_s elsif date 1 elsif other.date -1 else 0 end end |
#publisher ⇒ String
Generate URN for this identifier
15 16 17 |
# File 'lib/pubid/bsi/single_identifier.rb', line 15 attribute :publisher, Bsi::Components::Publisher, default: -> { Bsi::Components::Publisher.new(body: "BS") } |
#to_s(lang: :en, lang_single: false) ⇒ Object
37 38 39 |
# File 'lib/pubid/bsi/single_identifier.rb', line 37 def to_s(lang: :en, lang_single: false) render(format: :human, lang: lang, lang_single: lang_single) end |