Class: Subjoin::Link

Inherits:
Object
  • Object
show all
Includes:
Metable
Defined in:
lib/subjoin/link.rb

Overview

A link object

Instance Attribute Summary collapse

Attributes included from Metable

#meta

Instance Method Summary collapse

Methods included from Metable

#has_meta?, #load_meta

Constructor Details

#initialize(data) ⇒ Link

Returns a new instance of Link.



10
11
12
13
14
15
16
17
# File 'lib/subjoin/link.rb', line 10

def initialize(data)
  if data.is_a? String
    @href = URI(data)
  else
    @href = URI(data['href'])
    @meta = load_meta(data['meta'])
  end
end

Instance Attribute Details

#hrefObject (readonly)

The URL for this link

Returns:

  • String



8
9
10
# File 'lib/subjoin/link.rb', line 8

def href
  @href
end

Instance Method Details

#getDocument

Get the resource identified by the URL

Returns:



26
27
28
# File 'lib/subjoin/link.rb', line 26

def get
  Document.new(@href)
end

#to_sObject

Returns the #href attribute



20
21
22
# File 'lib/subjoin/link.rb', line 20

def to_s
  @href.to_s
end