Class: Edi::Wayfair::ListingGenerator::Attributes::HeatingElement
- Inherits:
-
BaseAttribute
- Object
- BaseAttribute
- Edi::Wayfair::ListingGenerator::Attributes::HeatingElement
- Defined in:
- app/services/edi/wayfair/listing_generator/attributes/heating_element.rb
Overview
Maps heating element type from Item to Wayfair's Heating Element attribute
Taxonomy Attribute ID: 186664
Datatype: MULTI_CHOICE
Values: Coil, Ceramic, Oil / Water Filled, Mica, PTC, Quartz, Carbon, Ribbon, Fan, Halogen, Infrared
Constant Summary collapse
- HEATING_ELEMENT_MAP =
Mapping of heating element.
{ 'coil' => 'Coil', 'ceramic' => 'Ceramic', 'oil' => 'Oil / Water Filled', 'oil_filled' => 'Oil / Water Filled', 'water_filled' => 'Oil / Water Filled', 'mica' => 'Mica', 'ptc' => 'PTC', 'quartz' => 'Quartz', 'carbon' => 'Carbon', 'carbon_fiber' => 'Carbon', 'ribbon' => 'Ribbon', 'fan' => 'Fan', 'halogen' => 'Halogen', 'infrared' => 'Infrared', 'radiant' => 'Infrared' }.with_indifferent_access.freeze
Constants inherited from BaseAttribute
Instance Attribute Summary
Attributes inherited from BaseAttribute
#attribute_definition, #catalog_item, #item, #taxonomy_attribute_id, #wayfair_schema
Instance Method Summary collapse
-
#value ⇒ Array<String>?
Returns the Wayfair heating element values for the item, inferring from the item name when no explicit spec value is present.
Methods inherited from BaseAttribute
attribute_name, #attribute_title, #build, #build_attribute_hash, #can_build?, #custom_values_allowed?, #datatype, #fetch_value, #format_boolean, #format_decimal, #initialize, #map_unit, #possible_values, #requirement, schema_titles, set_schema_titles, set_taxonomy_attribute_id, #valid_value?
Constructor Details
This class inherits a constructor from Edi::Wayfair::ListingGenerator::Attributes::BaseAttribute
Instance Method Details
#value ⇒ Array<String>?
Returns the Wayfair heating element values for the item, inferring
from the item name when no explicit spec value is present.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/services/edi/wayfair/listing_generator/attributes/heating_element.rb', line 35 def value element = fetch_value(:heating_element) || fetch_value(:heat_element) # Default for infrared heating panels is typically Carbon or Infrared if element.blank? # Check item name or description for hints name = item.name.to_s.downcase if name.include?('infrared') || name.include?('radiant') element = 'Infrared' elsif name.include?('carbon') element = 'Carbon' end end return nil if element.blank? # Handle array or single value elements = element.is_a?(Array) ? element : [element] elements.filter_map do |el| mapped = HEATING_ELEMENT_MAP[el.to_s.downcase.strip] mapped || el.to_s.titleize end.uniq end |