Class: Edi::Wayfair::ListingGenerator::Attributes::AirFlowType
- Inherits:
-
BaseAttribute
- Object
- BaseAttribute
- Edi::Wayfair::ListingGenerator::Attributes::AirFlowType
- Defined in:
- app/services/edi/wayfair/listing_generator/attributes/air_flow_type.rb
Overview
Maps air flow type from Item to Wayfair's Air Flow Type attribute
Taxonomy Attribute ID: 186663
Datatype: MULTI_CHOICE
Values: Radiant, Infrared, Forced Air, Convection, Multi-Directional
Constant Summary collapse
- AIR_FLOW_MAP =
{ 'radiant' => 'Radiant', 'infrared' => 'Infrared', 'forced_air' => 'Forced Air', 'forced air' => 'Forced Air', 'convection' => 'Convection', 'multi_directional' => 'Multi-Directional', 'multi-directional' => 'Multi-Directional' }.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
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, set_taxonomy_attribute_id, taxonomy_attribute_id, #valid_value?
Constructor Details
This class inherits a constructor from Edi::Wayfair::ListingGenerator::Attributes::BaseAttribute
Instance Method Details
#value ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/services/edi/wayfair/listing_generator/attributes/air_flow_type.rb', line 21 def value air_flow = fetch_value(:air_flow_type) || fetch_value(:heat_distribution) # Default for radiant heating products if air_flow.blank? name = item.name.to_s.downcase if name.include?('radiant') air_flow = 'Radiant' elsif name.include?('infrared') air_flow = 'Infrared' elsif name.include?('convection') air_flow = 'Convection' end end return nil if air_flow.blank? # Handle array or single value types = air_flow.is_a?(Array) ? air_flow : [air_flow] types.map do |t| mapped = AIR_FLOW_MAP[t.to_s.downcase.strip] mapped || t.to_s.titleize end.compact.uniq end |