Sha256: 8938859c8ccad95b615c4bd924e41d767862f5a6807124b77ed036032fe95e5a

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

module Stew
  module Store

    # Represents a price of an application in the steam store
    class AppOffer
      def self.create(node)
        return AppOfferSale.new(node) unless node.css('div.discount_final_price').empty?
        return AppOffer.new(node)
      end

      def initialize(node)
        @node = node
      end

      def price
        Stew.money @node.at_css('div.game_purchase_price').content.gsub(/[\n\t\r\s]/, '')
      end

      def regular_price
        price
      end

      def sale?
        false
      end

      def description
        description_empty? ? nil : @node.at_css('p').content
      end

      def name
        @node.at_css('h1').content.strip.gsub('Buy ','')
      end

      private

      def description_empty?
        @node.css('p').empty?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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