Sha256: 6fef43d9ab85cf0106955b707085dd36136d4ca3aa8877edb76359e8fe9dd884

Contents?: true

Size: 932 Bytes

Versions: 7

Compression:

Stored size: 932 Bytes

Contents

module Fassbinder
  class ItemBuilder
    attr_reader :item

    def initialize
      @item = Kosher::Item.new
    end

    def price=(price)
      cents    = price['Amount'].to_i
      currency = price['CurrencyCode']

      cents *= 100 if currency == 'JPY'

      @item.cents    = cents
      @item.currency = currency
    end

    def quantity=(quantity)
      @item.quantity = quantity.to_i
    end

    def add_condition(grade)
      condition = Kosher::Condition.new
      condition.grade =
        case grade
        when 'new'        then 1
        when 'mint'       then 2
        when 'verygood'   then 3
        when 'good'       then 4
        when 'acceptable' then 5
        else 6
        end

      @item.condition = condition
    end

    def add_description(text)
      text ||= ''
      description = Kosher::Description.new
      description.text = text

      @item.description = description
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fassbinder-0.0.15 lib/fassbinder/item_builder.rb
fassbinder-0.0.14 lib/fassbinder/item_builder.rb
fassbinder-0.0.13 lib/fassbinder/item_builder.rb
fassbinder-0.0.12 lib/fassbinder/item_builder.rb
fassbinder-0.0.11 lib/fassbinder/item_builder.rb
fassbinder-0.0.10 lib/fassbinder/item_builder.rb
fassbinder-0.0.9 lib/fassbinder/item_builder.rb