Class: Factoid::EntitoidRef

Inherits:
Object
  • Object
show all
Defined in:
lib/factoid/entitoid_ref.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, base) ⇒ EntitoidRef


10
11
12
13
# File 'lib/factoid/entitoid_ref.rb', line 10

def initialize(uri, base)
  @uri = Addressable::URI.parse(uri)
  @base = base
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri


15
16
17
# File 'lib/factoid/entitoid_ref.rb', line 15

def uri
  @uri
end

Class Method Details

.from_xml(elem) ⇒ Object


43
44
45
46
47
48
# File 'lib/factoid/xml.rb', line 43

def EntitoidRef.from_xml(elem)
  href = elem.attr('xlink:href')
  base = elem.document.url

  return EntitoidRef.new(href, base)
end

Instance Method Details

#derefObject


21
22
23
# File 'lib/factoid/entitoid_ref.rb', line 21

def deref
  return Entitoid.from_xml(full_uri)
end

#eql?(other) ⇒ Boolean


25
26
27
28
29
30
31
# File 'lib/factoid/entitoid_ref.rb', line 25

def eql?(other)
  if other.class != self.class
    return false
  end

  return other.full_uri == self.full_uri
end

#full_uriObject


17
18
19
# File 'lib/factoid/entitoid_ref.rb', line 17

def full_uri
  return Addressable::URI.join(@base, @uri)
end