Class: Pubid::Nist::Components::Stage
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Nist::Components::Stage
- Defined in:
- lib/pubid/nist/components/stage.rb
Overview
Constant Summary collapse
- STAGES =
Load stages from V1 YAML config
YAML.load_file( File.join(File.dirname(__FILE__), "../../../../archived-gems/pubid-nist/stages.yaml"), ).freeze
Instance Method Summary collapse
-
#to_s(format = :short) ⇒ String
Render stage in specified format.
-
#validate! ⇒ Object
Validate stage id and type against YAML config.
Instance Method Details
#to_s(format = :short) ⇒ String
Render stage in specified format
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pubid/nist/components/stage.rb', line 28 def to_s(format = :short) return "" if id.nil? || type.nil? case format when :short, :mr "#{id}#{type}" when :long "(#{STAGES['id'][id]} #{STAGES['type'][type]})" else "#{id}#{type}" end end |
#validate! ⇒ Object
Validate stage id and type against YAML config
42 43 44 45 46 47 48 49 |
# File 'lib/pubid/nist/components/stage.rb', line 42 def validate! unless STAGES["id"].key?(id.to_s) raise ArgumentError, "Invalid stage id: #{id.inspect}" end unless STAGES["type"].key?(type.to_s) raise ArgumentError, "Invalid stage type: #{type.inspect}" end end |