Class: OPDS::Support::Link

Inherits:
Array
  • Object
show all
Includes:
Logging
Defined in:
lib/opds/support/linkset.rb

Overview

A link is actually an array composed as :

[rel, url , title, mimetype, opds:price, opds:currency]

Direct Known Subclasses

Facet

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#log, log

Constructor Details

#initialize(array, browser = OPDS::Support::Browser.new) ⇒ Link

Returns a new instance of Link.



11
12
13
14
15
16
17
# File 'lib/opds/support/linkset.rb', line 11

def initialize(array,browser=OPDS::Support::Browser.new) 
	@browser=browser
		unless browser.current_location.nil?
			array[1]=URI.join(browser.current_location,array[1]).to_s
		end
	super array
end

Instance Attribute Details

#browserOPDS::Support::Browser

Returns Browser to use with this link.

Returns:



9
10
11
# File 'lib/opds/support/linkset.rb', line 9

def browser
  @browser
end

Instance Method Details

#currencyString

Returns link opds curreny.

Returns:

  • (String)

    link opds curreny



57
58
59
# File 'lib/opds/support/linkset.rb', line 57

def currency
	self[5]
end

#inspectObject



27
28
29
# File 'lib/opds/support/linkset.rb', line 27

def inspect
	"[#{self.map{|e| (e.is_a?(String) && e.size > 100 ? "#{e[0..98]}...".inspect: e.inspect ) }.join(', ')}]"
end

Will go parsing the resource at this url. Proxy to Feed.parse_url

Returns:

See Also:



23
24
25
# File 'lib/opds/support/linkset.rb', line 23

def navigate
Feed.parse_url(self[1],browser)
end

#priceString

Returns link opds price.

Returns:

  • (String)

    link opds price



52
53
54
# File 'lib/opds/support/linkset.rb', line 52

def price
	self[4]
end

#relString

Returns link rel value.

Returns:

  • (String)

    link rel value



37
38
39
# File 'lib/opds/support/linkset.rb', line 37

def rel
	self[0]
end

#titleString

Returns link title.

Returns:

  • (String)

    link title



42
43
44
# File 'lib/opds/support/linkset.rb', line 42

def title
	self[2]
end

#typeString

Returns link mimetype.

Returns:

  • (String)

    link mimetype



47
48
49
# File 'lib/opds/support/linkset.rb', line 47

def type
	self[3]
end

#urlString

Returns link url.

Returns:

  • (String)

    link url



32
33
34
# File 'lib/opds/support/linkset.rb', line 32

def url 
	self[1]
end