Class: ExteriorWall

Inherits:
ApplicationRecord show all
Includes:
Models::HeatLossable
Defined in:
app/models/exterior_wall.rb

Overview

== Schema Information

Table name: exterior_walls
Database name: primary

id :integer not null, primary key
area :float
user_u_value :float
exterior_wall_insulation_type_id :integer
exterior_wall_type_id :integer
room_configuration_id :integer

Indexes

exterior_walls_exterior_wall_insulation_type_id_idx (exterior_wall_insulation_type_id)
exterior_walls_exterior_wall_type_id_idx (exterior_wall_type_id)
exterior_walls_room_configuration_id_idx (room_configuration_id)

Foreign Keys

exterior_walls_exterior_wall_insulation_type_id_fk (exterior_wall_insulation_type_id => exterior_wall_insulation_types.id)
exterior_walls_exterior_wall_type_id_fk (exterior_wall_type_id => exterior_wall_types.id)
exterior_walls_room_configuration_id_fk (room_configuration_id => room_configurations.id) ON DELETE => cascade

Constant Summary

Constants included from HeatLossableConstants

HeatLossableConstants::BTU_PER_HOUR_PER_WATT, HeatLossableConstants::HIGH_U_VALUE_THRESHOLD, HeatLossableConstants::HLC_PRIMARY_OK_THRESHOLD, HeatLossableConstants::INFILTRATION_AREA_FACTORS, HeatLossableConstants::INFILTRATION_FIREPLACE_FACTORS, HeatLossableConstants::INFILTRATION_SEALING_FACTORS, HeatLossableConstants::PIE_CHART_FLAG_COLORS, HeatLossableConstants::PIE_CHART_OK_COLORS

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Has many collapse

Belongs to collapse

Instance Method Summary collapse

Methods included from Models::HeatLossable

#children_heat_loss_recursive, #get_children_heat_loss, #get_heat_loss, #get_self_and_children_heat_loss, #get_u_value, #heat_loss_children_recursive, #insulation_type, #reset_room_last_heat_loss, #self_and_children_heat_loss_recursive

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#areaFloat (readonly)

Returns:

  • (Float)


50
# File 'app/models/exterior_wall.rb', line 50

validates :area, numericality: { less_than_or_equal_to: 9999.9, greater_than: 0.0 }

Instance Method Details

#check_insulation_or_u_valuevoid (protected)

This method returns an undefined value.



78
79
80
81
82
83
# File 'app/models/exterior_wall.rb', line 78

def check_insulation_or_u_value
  return unless user_u_value.blank? && (exterior_wall_type.nil? || exterior_wall_insulation_type.nil?)

  errors.add(:exterior_wall_type_id, "and insulation type required OR")
  errors.add(:user_u_value, "required")
end

#doorsActiveRecord::Relation<Door>

Returns:

  • (ActiveRecord::Relation<Door>)


40
# File 'app/models/exterior_wall.rb', line 40

has_many :doors, -> { order("doors.id ASC NULLS LAST") }, dependent: :destroy

#exterior_wall_insulation_typeExteriorWallInsulationType?

Returns:



46
# File 'app/models/exterior_wall.rb', line 46

belongs_to :exterior_wall_insulation_type, optional: true

#exterior_wall_typeExteriorWallType?

Returns:



44
# File 'app/models/exterior_wall.rb', line 44

belongs_to :exterior_wall_type, optional: true

#heat_loss_childrenArray<Window, Door>

Returns:



57
58
59
# File 'app/models/exterior_wall.rb', line 57

def heat_loss_children
  windows + doors
end

#heat_loss_nameString

Returns:

  • (String)


71
72
73
# File 'app/models/exterior_wall.rb', line 71

def heat_loss_name
  name
end

#nameString

Returns:

  • (String)


62
63
64
65
66
67
68
# File 'app/models/exterior_wall.rb', line 62

def name
  "Exterior Wall: #{begin
    (room_configuration.exterior_wall_ids.index(id) + 1)
  rescue StandardError
    'New'
  end}"
end

#room_configurationRoomConfiguration?

Returns:

Validations:



42
# File 'app/models/exterior_wall.rb', line 42

belongs_to :room_configuration, optional: true

#windowsActiveRecord::Relation<Window>

Returns:

  • (ActiveRecord::Relation<Window>)


38
# File 'app/models/exterior_wall.rb', line 38

has_many :windows, -> { order("windows.id ASC NULLS LAST") }, dependent: :destroy