Class: Discodactyl::JRD::Link

Inherits:
Struct
  • Object
show all
Defined in:
lib/discodactyl/jrd/link.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#hrefObject

Returns the value of attribute href

Returns:

  • (Object)

    the current value of href


5
6
7
# File 'lib/discodactyl/jrd/link.rb', line 5

def href
  @href
end

#rawObject

Returns the value of attribute raw


6
7
8
# File 'lib/discodactyl/jrd/link.rb', line 6

def raw
  @raw
end

#relObject

Returns the value of attribute rel

Returns:

  • (Object)

    the current value of rel


5
6
7
# File 'lib/discodactyl/jrd/link.rb', line 5

def rel
  @rel
end

#templateObject

Returns the value of attribute template

Returns:

  • (Object)

    the current value of template


5
6
7
# File 'lib/discodactyl/jrd/link.rb', line 5

def template
  @template
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title


5
6
7
# File 'lib/discodactyl/jrd/link.rb', line 5

def title
  @title
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type


5
6
7
# File 'lib/discodactyl/jrd/link.rb', line 5

def type
  @type
end

Class Method Details

.parse(element) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/discodactyl/jrd/link.rb', line 8

def parse(element)
  self.new.tap do |link|
    begin
      link.rel = element['rel']
      link.type = element['type']
      link.href = element['href']
      link.title = element['title']
      link.template = URITemplate.new(element['template']) unless link.href
      link.raw = element
    rescue
      raise "Couldn't parse #{link} into a JRD Link"
    end
  end
end