Class: Fassbinder::ItemBuilder
- Inherits:
-
Object
- Object
- Fassbinder::ItemBuilder
- Defined in:
- lib/fassbinder/item_builder.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
- #add_condition(grade) ⇒ Object
- #add_description(text) ⇒ Object
-
#initialize ⇒ ItemBuilder
constructor
A new instance of ItemBuilder.
- #price=(price) ⇒ Object
- #quantity=(quantity) ⇒ Object
Constructor Details
#initialize ⇒ ItemBuilder
Returns a new instance of ItemBuilder.
5 6 7 |
# File 'lib/fassbinder/item_builder.rb', line 5 def initialize @item = Kosher::Item.new end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
3 4 5 |
# File 'lib/fassbinder/item_builder.rb', line 3 def item @item end |
Instance Method Details
#add_condition(grade) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fassbinder/item_builder.rb', line 23 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 |
#add_description(text) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/fassbinder/item_builder.rb', line 38 def add_description(text) text ||= '' description = Kosher::Description.new description.text = text @item.description = description end |
#price=(price) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/fassbinder/item_builder.rb', line 9 def price=(price) cents = price['Amount'].to_i currency = price['CurrencyCode'] cents *= 100 if currency == 'JPY' @item.cents = cents @item.currency = currency end |
#quantity=(quantity) ⇒ Object
19 20 21 |
# File 'lib/fassbinder/item_builder.rb', line 19 def quantity=(quantity) @item.quantity = quantity.to_i end |