Class: Obp::Access::Urn
- Inherits:
-
Object
- Object
- Obp::Access::Urn
- Defined in:
- lib/obp/access/urn.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(raw) ⇒ Urn
constructor
A new instance of Urn.
- #safe ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(raw) ⇒ Urn
Returns a new instance of Urn.
6 7 8 9 10 11 |
# File 'lib/obp/access/urn.rb', line 6 def initialize(raw) @raw = raw parts = raw.split(":") @language = parts.last @base = parts[0...-1].join(":") end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
4 5 6 |
# File 'lib/obp/access/urn.rb', line 4 def base @base end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
4 5 6 |
# File 'lib/obp/access/urn.rb', line 4 def language @language end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
4 5 6 |
# File 'lib/obp/access/urn.rb', line 4 def raw @raw end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
21 22 23 |
# File 'lib/obp/access/urn.rb', line 21 def ==(other) other.is_a?(self.class) && raw == other.raw end |
#hash ⇒ Object
26 27 28 |
# File 'lib/obp/access/urn.rb', line 26 def hash raw.hash end |
#safe ⇒ Object
13 14 15 |
# File 'lib/obp/access/urn.rb', line 13 def safe @safe ||= raw.tr(":", "-") end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/obp/access/urn.rb', line 17 def to_s raw end |