class ApmexPrice

Constants

BUY_CSS
DOLLARS_REGEX

Attributes

buy[RW]
page[RW]
url[RW]

Public Class Methods

new(url) click to toggle source
# File lib/apmex-price.rb, line 10
def initialize(url)
        @url = url
        match()
end

Public Instance Methods

match() click to toggle source
# File lib/apmex-price.rb, line 15
def match
              @page = Nokogiri::HTML(open(@url))
              @buy = match_dollars(BUY_CSS)
      end
match_dollars(dollars_css) click to toggle source
# File lib/apmex-price.rb, line 20
def match_dollars(dollars_css)
        dollars_text = @page.css(dollars_css).text
        dollars_match = DOLLARS_REGEX.match(dollars_text)

        if dollars_match != nil
                dollars_match[1].gsub(',', '').to_f
        else
                0.0
        end
end