class NistPubid::Stage

Attributes

original_code[RW]
stage[RW]

Public Class Methods

new(original_code) click to toggle source
# File lib/nist_pubid/stage.rb, line 7
def initialize(original_code)
  self.original_code = original_code
  @stage = self.class.regexp.match(original_code)&.[](1)
end
parse(code) click to toggle source
# File lib/nist_pubid/stage.rb, line 25
def self.parse(code)
  new(regexp.match(code)&.to_s)
end
regexp() click to toggle source
# File lib/nist_pubid/stage.rb, line 29
def self.regexp
  /\((#{STAGES.keys.join('|')})\)/
end

Public Instance Methods

nil?() click to toggle source
# File lib/nist_pubid/stage.rb, line 33
def nil?
  @stage.nil?
end
to_s(format = :short) click to toggle source
# File lib/nist_pubid/stage.rb, line 12
def to_s(format = :short)
  return "" if nil?

  case format
  when :short
    "(#{@stage})"
  when :mr
    @stage
  else
    STAGES[@stage]
  end
end