Class: Pubid::Ieee::Ire::Identifier
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Ieee::Ire::Identifier
- Defined in:
- lib/pubid/ieee/ire/identifier.rb
Overview
Base class for IRE identifiers IRE (Institute of Radio Engineers): 1912-1963
Class Method Summary collapse
-
.parse(input) ⇒ Object
Parse IRE identifier string.
Instance Method Summary collapse
-
#initialize(**args) ⇒ Identifier
constructor
A new instance of Identifier.
- #to_s ⇒ Object
Constructor Details
#initialize(**args) ⇒ Identifier
Returns a new instance of Identifier.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pubid/ieee/ire/identifier.rb', line 16 def initialize(**args) super() # Handle number as string or Code object if args[:number].is_a?(String) self.number = Components::Code.parse(args[:number]) elsif args[:number] self.number = args[:number] end # Set other attributes attrs = self.class.attributes args.each do |key, value| next if key == :number setter = :"#{key}=" public_send(setter, value) if attrs.key?(key) end end |
Class Method Details
Instance Method Details
#to_s ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pubid/ieee/ire/identifier.rb', line 43 def to_s parts = [] # Year comes FIRST in IRE format - render as 2-digit short year if year short_year = year.between?(1900, 1999) ? year - 1900 : year parts << short_year.to_s end parts << publisher parts << type if type parts << number.to_s if number parts.join(" ") end |