Class: Pubid::Iec::Stage
- Inherits:
-
Core::Stage
- Object
- Core::Stage
- Pubid::Iec::Stage
- Defined in:
- lib/pubid/iec/stage.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(config:, abbr: nil, harmonized_code: nil) ⇒ Stage
constructor
A new instance of Stage.
- #to_s(format = :short) ⇒ Object
Constructor Details
#initialize(config:, abbr: nil, harmonized_code: nil) ⇒ Stage
Returns a new instance of Stage.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pubid/iec/stage.rb', line 4 def initialize(config:, abbr: nil, harmonized_code: nil) @config = config @abbr = abbr&.to_s if harmonized_code @harmonized_code = if harmonized_code.is_a?(Pubid::Core::HarmonizedStageCode) harmonized_code else Pubid::Core::HarmonizedStageCode.new(harmonized_code, config: config) end @abbr ||= lookup_abbr(@harmonized_code.stages) end if abbr if config.stages["project_stages"].key?(abbr.to_s) @harmonized_code ||= Pubid::Core::HarmonizedStageCode.new(config.stages["project_stages"][abbr.to_s], config: config) # update abbreviation with identifier's stage @abbr = lookup_abbr(@harmonized_code.stages) else raise Pubid::Core::Errors::StageInvalidError, "#{abbr} is not valid stage" unless config.stages["abbreviations"].key?(abbr.to_s) @harmonized_code ||= Pubid::Core::HarmonizedStageCode.new(lookup_code(abbr), config: config) end end end |
Instance Method Details
#to_s(format = :short) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/pubid/iec/stage.rb', line 30 def to_s(format = :short) case format when :short empty_abbr? ? "" : abbr else @harmonized_code.to_s end end |