Class: Obp::Access::Urn

Inherits:
Object
  • Object
show all
Defined in:
lib/obp/access/urn.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#baseObject (readonly)

Returns the value of attribute base.



4
5
6
# File 'lib/obp/access/urn.rb', line 4

def base
  @base
end

#languageObject (readonly)

Returns the value of attribute language.



4
5
6
# File 'lib/obp/access/urn.rb', line 4

def language
  @language
end

#rawObject (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

#hashObject



26
27
28
# File 'lib/obp/access/urn.rb', line 26

def hash
  raw.hash
end

#safeObject



13
14
15
# File 'lib/obp/access/urn.rb', line 13

def safe
  @safe ||= raw.tr(":", "-")
end

#to_sObject



17
18
19
# File 'lib/obp/access/urn.rb', line 17

def to_s
  raw
end