class ItemPriceParser
Attributes
country[R]
html[R]
Public Class Methods
new(html, country)
click to toggle source
# File lib/discogs/wishlist/parsers/item_price_parser.rb, line 5 def initialize(html, country) @html = html @country = country end
Public Instance Methods
parse()
click to toggle source
# File lib/discogs/wishlist/parsers/item_price_parser.rb, line 10 def parse return [] unless rows.length.positive? rows.map do |row| price = row.search(".item_price .price").text.gsub(/[^\d.]+/, "") shipping = row.search(".item_shipping").first.text.gsub(/[^\d.]+/, "") return nil if price.nil? || shipping.nil? { price: Monetize.parse(price, country.currency.iso_code), shipping: Monetize.parse(shipping, country.currency.iso_code) } end.compact end
Private Instance Methods
parsed_html()
click to toggle source
# File lib/discogs/wishlist/parsers/item_price_parser.rb, line 34 def parsed_html @parsed_html ||= Nokogiri::HTML(html.body) end
rows()
click to toggle source
# File lib/discogs/wishlist/parsers/item_price_parser.rb, line 30 def rows @rows ||= parsed_html.search(".mpitems tbody tr") end