Class: Pubid::Iso::Type
- Inherits:
-
Object
- Object
- Pubid::Iso::Type
- Defined in:
- lib/pubid/iso/type.rb
Constant Summary collapse
- TYPE_NAMES =
{ tr: { long: "Technical Report", short: "TR", }, ts: { long: "Technical Specification", short: "TS", }, is: { long: "International Standard", short: "IS", }, pas: { long: "Publicly Available Specification", short: "PAS", }, isp: { long: "International Standardized Profiles", short: "ISP", }, guide: { long: "Guide", short: "Guide", }, dir: { long: "Directives", short: "DIR", }, dpas: { long: "Publicly Available Specification Draft", short: "DPAS", }, cor: { short: "Cor", }, amd: { short: "Amd", }, r: { long: "Recommendation", short: "R", }, }.freeze
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type) ⇒ Type
constructor
Create new type.
- #to_s(format = :short) ⇒ Object
Constructor Details
#initialize(type) ⇒ Type
Create new type
52 53 54 55 56 |
# File 'lib/pubid/iso/type.rb', line 52 def initialize(type) raise Errors::WrongTypeError, "#{type} type is not available" unless TYPE_NAMES.key?(type) @type = type end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/pubid/iso/type.rb', line 3 def type @type end |
Class Method Details
.has_type?(type) ⇒ Boolean
77 78 79 80 81 |
# File 'lib/pubid/iso/type.rb', line 77 def self.has_type?(type) TYPE_NAMES.any? do |_, v| v[:short] == type end end |
.parse(type_string) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/pubid/iso/type.rb', line 58 def self.parse(type_string) TYPE_NAMES.each do |type, values| return new(type) if values[:short] == type_string end raise Errors::ParseTypeError, "Cannot parse '#{type_string}' type" end |
Instance Method Details
#==(other) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/pubid/iso/type.rb', line 69 def ==(other) return type == other if other.is_a?(Symbol) return false if other.nil? type == other.type end |
#to_s(format = :short) ⇒ Object
65 66 67 |
# File 'lib/pubid/iso/type.rb', line 65 def to_s(format = :short) TYPE_NAMES[type][format] end |