Class: Item::HeatingElementLine

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::API, ActiveModel::Attributes, ActiveModel::Validations::Callbacks, StripAttributes
Defined in:
app/services/item/heating_element_line.rb

Instance Method Summary collapse

Instance Method Details

#imperial_cold_lead_lengthObject



30
31
32
33
# File 'app/services/item/heating_element_line.rb', line 30

def imperial_cold_lead_length
  return nil if cold_lead_length.nil?
  UnitConversions.inches_to_feetinches(cold_lead_length)
end

#imperial_lengthObject



26
27
28
# File 'app/services/item/heating_element_line.rb', line 26

def imperial_length
  UnitConversions.inches_to_feetinches(length)
end

#imperial_widthObject

Renders width in plain inches if < 12 or converts to feet and inches notation



22
23
24
# File 'app/services/item/heating_element_line.rb', line 22

def imperial_width
  UnitConversions.inches_to_feetinches(width)
end

#merge_by_length(other_heating_element_line) ⇒ Object



35
36
37
38
39
40
# File 'app/services/item/heating_element_line.rb', line 35

def merge_by_length(other_heating_element_line)
  %i(length amps watts).each do |col|
    public_send(:"#{col}=", public_send(col) + other_heating_element_line.public_send(col))
  end
  self
end

#volts_with_alternative_volts(alternative_volts_explanation) ⇒ Object



42
43
44
45
46
47
48
49
# File 'app/services/item/heating_element_line.rb', line 42

def volts_with_alternative_volts(alternative_volts_explanation)
  if alternative_volts.present?
    symbol = alternative_volts_explanation.select{|sym,a_volts| a_volts == alternative_volts}.keys.first
    "#{volts}<sup>#{symbol}</sup>"
  else
    volts
  end
end