Class: XRD::Link

Inherits:
Object
  • Object
show all
Includes:
SAXMachine, Properties
Defined in:
lib/xrd/link.rb

Instance Method Summary collapse

Methods included from Properties

included, #properties

Instance Method Details

#inspectString

Returns a String representation of the link object’s state.

Returns:

  • (String)

    The Link object’s state, as a String.



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/xrd/link.rb', line 32

def inspect
  if self.template
    sprintf(
      "#<%s:%#0x TEMPLATE:%s>",
      self.class.to_s, self.object_id, self.template
    )
  else
    sprintf(
      "#<%s:%#0x HREF:%s>",
      self.class.to_s, self.object_id, self.href
    )
  end
end

#title(lang = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/xrd/link.rb', line 17

def title(lang=nil)
  title = self.titles.detect { |t| t.lang == lang }
  unless title
    title = self.titles.detect { |t| t.lang == nil }
  end
  unless title
    title = self.titles.detect { |t| t.lang == 'en' }
  end
  return title
end