Class: Valkyrie::ID

Inherits:
Object
  • Object
show all
Defined in:
lib/valkyrie/id.rb

Overview

A simple ID class to keep IDs distinguished from strings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ ID

Returns a new instance of ID.



7
8
9
# File 'lib/valkyrie/id.rb', line 7

def initialize(id)
  @id = id.to_s
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/valkyrie/id.rb', line 5

def id
  @id
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


17
18
19
# File 'lib/valkyrie/id.rb', line 17

def eql?(other)
  other.class == self.class && other.state == state
end

#to_sObject



11
12
13
# File 'lib/valkyrie/id.rb', line 11

def to_s
  id
end

#to_uriObject



22
23
24
25
# File 'lib/valkyrie/id.rb', line 22

def to_uri
  return RDF::Literal.new(id.to_s, datatype: RDF::URI("http://example.com/valkyrie_id")) if id.to_s.include?("://")
  ::RDF::URI(ActiveFedora::Base.id_to_uri(id))
end