Class: Edi::Wayfair::ListingGenerator::Attributes::BtuOutput

Inherits:
BaseAttribute
  • Object
show all
Defined in:
app/services/edi/wayfair/listing_generator/attributes/btu_output.rb

Overview

Maps BTU output from Item to Wayfair's BTU Output attribute
Taxonomy Attribute ID: 892
Datatype: DECIMAL

Constant Summary

Constants inherited from BaseAttribute

Edi::Wayfair::ListingGenerator::Attributes::BaseAttribute::UNIT_MAPPINGS

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, 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

#valueString?

Resolve the BTU output value for this item, falling back to a
watts-derived estimate (1 watt ≈ 3.412 BTU) when no spec is present.

Returns:

  • (String, nil)

    decimal-formatted BTU output, or nil when undetermined



14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/edi/wayfair/listing_generator/attributes/btu_output.rb', line 14

def value
  # Try spec first, then fall back to calculated BTU from watts
  btu = fetch_value(:btu_output) || fetch_value(:btus)

  # If no BTU specified, calculate from watts (1 watt ≈ 3.412 BTU)
  btu = (item.watts * 3.412).round(0) if btu.blank? && item.watts.present? && item.watts > 0

  return nil unless btu.present? && btu > 0

  format_decimal(btu)
end