Class: Pubid::Nist::Stage

Inherits:
Core::Entity
  • Object
show all
Defined in:
lib/pubid/nist/stage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, type:) ⇒ Stage

Returns a new instance of Stage.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
# File 'lib/pubid/nist/stage.rb', line 7

def initialize(id:, type:)
  @id, @type = id.to_s.downcase, type.to_s.downcase

  raise ArgumentError, "id cannot be #{id.inspect}" unless STAGES['id'].key?(@id)
  raise ArgumentError, "type cannot be #{type.inspect}" unless STAGES['type'].key?(@type)
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/pubid/nist/stage.rb', line 5

def id
  @id
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/pubid/nist/stage.rb', line 5

def type
  @type
end

Instance Method Details

#to_s(format = :short) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pubid/nist/stage.rb', line 14

def to_s(format = :short)
  return "" if nil?

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