Class: Pubid::Ieee::Identifiers::Nesc::Standard

Inherits:
Base show all
Includes:
CodeNumber
Defined in:
lib/pubid/ieee/identifiers/nesc/standard.rb

Overview

Standard NESC identifier with C2-YYYY format

Represents the standard National Electrical Safety Code publications using the C2 designation followed by publication year.

Examples:

nesc = Pubid::Ieee.parse("C2-1997 National Electric Safety Code")
nesc.to_s  # => "C2-1997 National Electrical Safety Code"

Instance Attribute Summary

Attributes inherited from Pubid::Ieee::Identifier

#code_obj, #draft_obj

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CodeNumber

#code_obj, included, #initialize, #rebuild_code_obj_from_split, #sync_split_from_code_obj

Methods inherited from Base

#draft?, #initialize, #name_portion, #publisher_portion, #trademark_symbol

Methods inherited from Pubid::Ieee::Identifier

additional_identifier_classes, #code, #draft, #draft_month, #exclude, from_hash, #initialize, #mr_number_with_part, #mr_publisher, #mr_type, #mr_year, parse, parse_single, #publisher, #to_hash

Methods inherited from Pubid::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_type, #mr_year, #new_edition_of?, polymorphic_type_map, #related_to?, #render, #resolve_urn_generator, #root, #sibling_of?, #supplement_of?, #to_hash, #to_mr_string, #to_slug, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year

Class Method Details

.polymorphic_nameObject

Distinct from Identifiers::Standard, whose derived polymorphic name is also "pubid:ieee:standard".



20
21
22
# File 'lib/pubid/ieee/identifiers/nesc/standard.rb', line 20

def self.polymorphic_name
  "pubid:ieee:nesc-standard"
end

Instance Method Details

#to_s(trademark: false) ⇒ String

Render standard NESC identifier

Parameters:

  • trademark (Boolean) (defaults to: false)

    append the IEEE trademark symbol (™/®)

Returns:

  • (String)

    C2-YYYY format (bare "C2" when the year is absent, e.g. a partial reference produced by #exclude(:year))



29
30
31
32
33
34
35
36
# File 'lib/pubid/ieee/identifiers/nesc/standard.rb', line 29

def to_s(trademark: false)
  # Unlike the year-first NESC editions, this form renders a code, so
  # the mark goes after it and before the year — as everywhere else.
  code_part = "C2"
  code_part += trademark_symbol if trademark
  code_part += "-#{year}" if year
  "#{code_part} National Electrical Safety Code"
end