Sha256: deb49385d1daa6e1e58028d6e8ddda809e9975947e6354a8abed5aacf6237b43

Contents?: true

Size: 748 Bytes

Versions: 2

Compression:

Stored size: 748 Bytes

Contents

module Stew
  module Store
    # A single sale in the Steam Store
    class Sale
      def initialize(node)
        @node = node
      end

      def name
        @node.at_css("div.tab_desc").at_css("h4").content
      end

      def price
        Stew.money @node.at_css("div.tab_price").children.last.content.strip
      end

      def original_price
        possible_price = Stew.money(self.class.content_or_nil(@node.at_css("div.tab_price").at_css('strike')))
        return price if possible_price.fractional == 0
        possible_price
      end

      def app_id
        @node.to_s.match(/tab_row_Discounts_([0-9]+)/)[1].to_i
      end

    private
      def self.content_or_nil(item)
        item && item.content
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stew-0.6.0 lib/stew/store/sale.rb
stew-0.5.3 lib/stew/store/sale.rb