Class: PackwizardParser::ItemParser
- Inherits:
-
Object
- Object
- PackwizardParser::ItemParser
- Defined in:
- lib/packwizard_parser/item_parser.rb
Instance Method Summary collapse
-
#parse(row) ⇒ Item
Parser for extracting a single item row from PackWizard JSON.
Instance Method Details
#parse(row) ⇒ Item
Parser for extracting a single item row from PackWizard JSON
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/packwizard_parser/item_parser.rb', line 9 def parse(row) name = extract_name(row) description = extract_description(row) weight_per_item = extract_weight(row) quantity = extract_quantity(row) image_url = extract_image_url(row) consumable = extract_consumable_flag(row) total_consumable_weight = consumable ? weight_per_item * quantity : nil # In PackWizard, the returned worn weight is a single items weight regardless of quantity worn = extract_worn_flag(row) worn_quantity = worn ? 1 : 0 total_worn_weight = weight_per_item * worn_quantity total_weight = weight_per_item * quantity Item.new( name: name, description: description, weight: weight_per_item, total_weight: total_weight, quantity: quantity, image_url: image_url, consumable: consumable, total_consumable_weight: total_consumable_weight, worn: worn, worn_quantity: worn_quantity, total_worn_weight: total_worn_weight ) end |