Skip to content

Commit

Permalink
Support for opds:price
Browse files Browse the repository at this point in the history
  • Loading branch information
zetaben committed Aug 31, 2010
1 parent 97168ce commit a722eda
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lib/opds/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,20 @@ def serialize!
text=n.attributes['title'].value unless n.attributes['title'].nil?
link=n.attributes['href'].value
type=n.attributes['type'].value unless n.attributes['type'].nil?
price=nil
currency=nil
oprice=n.at('./opds:price',@namespaces)
if oprice
price=text(oprice)
currency=oprice.attributes['currencycode'].value unless oprice.attributes['currencycode'].nil?
end

unless n.attributes['rel'].nil?
n.attributes['rel'].value.split.each do |rel|
@links.push(rel,link,text,type)
@links.push(rel,link,text,type,price,currency)
end
else
@links.push(nil,link,text,type)
@links.push(nil,link,text,type,price,currency)
end
end
@dcmetas=Hash.new
Expand Down
14 changes: 12 additions & 2 deletions lib/opds/support/linkset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def title
def type
self[3]
end

def price
self[4]
end

def currency
self[5]
end

end

Expand Down Expand Up @@ -74,8 +82,10 @@ def each(&block)
@store.each(&block)
end

def push(rel,link,text=nil,type=nil)
self[rel]=[link,text,type]
def push(rel,link,text=nil,type=nil, price=nil, currency=nil)
tab=[link,text,type]
tab+=[price.to_f,currency] unless price.nil?
self[rel]=tab
end

def link_url(k)
Expand Down

0 comments on commit a722eda

Please sign in to comment.