Class: Door
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Door
- Includes:
- Models::HeatLossable
- Defined in:
- app/models/door.rb
Overview
== Schema Information
Table name: doors
Database name: primary
id :integer not null, primary key
area :float
user_u_value :float
door_core_type_id :integer
door_frame_type_id :integer
door_insulation_type_id :integer
door_type_id :integer
exterior_wall_id :integer
Indexes
doors_door_core_type_id_idx (door_core_type_id)
doors_door_frame_type_id_idx (door_frame_type_id)
doors_door_insulation_type_id_idx (door_insulation_type_id)
doors_door_type_id_idx (door_type_id)
doors_exterior_wall_id_idx (exterior_wall_id)
Foreign Keys
doors_door_core_type_id_fk (door_core_type_id => door_core_types.id)
doors_door_frame_type_id_fk (door_frame_type_id => door_frame_types.id)
doors_door_insulation_type_id_fk (door_insulation_type_id => door_insulation_types.id)
doors_door_type_id_fk (door_type_id => door_types.id)
doors_exterior_wall_id_fk (exterior_wall_id => exterior_walls.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
- #area ⇒ Float readonly
Belongs to collapse
- #door_core_type ⇒ DoorCoreType?
- #door_frame_type ⇒ DoorFrameType?
- #door_insulation_type ⇒ DoorInsulationType?
- #door_type ⇒ DoorType?
- #exterior_wall ⇒ ExteriorWall?
Delegated Instance Attributes collapse
-
#room_configuration ⇒ Object
Alias for Exterior_wall#room_configuration.
Instance Method Summary collapse
- #check_insulation_or_u_value ⇒ void protected
- #check_sibling_areas_less_than_parent ⇒ void protected
- #heat_loss_name ⇒ void
- #name ⇒ void
- #set_door_insulation_type ⇒ void protected
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, #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
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#area ⇒ Float (readonly)
49 |
# File 'app/models/door.rb', line 49 validates :area, numericality: { less_than_or_equal_to: 9999.9, greater_than: 0.0 } |
Instance Method Details
#check_insulation_or_u_value ⇒ void (protected)
This method returns an undefined value.
88 89 90 91 92 93 |
# File 'app/models/door.rb', line 88 def check_insulation_or_u_value return unless user_u_value.blank? && (door_type.nil? || door_core_type.nil? || door_frame_type.nil? || door_insulation_type.nil?) errors.add(:door_type_id, ", core, and frame type required OR") errors.add(:user_u_value, "required") end |
#check_sibling_areas_less_than_parent ⇒ void (protected)
This method returns an undefined value.
83 84 85 |
# File 'app/models/door.rb', line 83 def check_sibling_areas_less_than_parent errors.add(:area, "plus areas of other windows and doors can't exceed exterior wall area") if area && ((area + exterior_wall.windows.to_a.sum(&:area) + exterior_wall.doors.to_a.reject { |d| d.id == (id || -1) }.sum(&:area)) >= exterior_wall.area) end |
#door_core_type ⇒ DoorCoreType?
40 |
# File 'app/models/door.rb', line 40 belongs_to :door_core_type, optional: true |
#door_frame_type ⇒ DoorFrameType?
42 |
# File 'app/models/door.rb', line 42 belongs_to :door_frame_type, optional: true |
#door_insulation_type ⇒ DoorInsulationType?
44 |
# File 'app/models/door.rb', line 44 belongs_to :door_insulation_type, optional: true |
#door_type ⇒ DoorType?
38 |
# File 'app/models/door.rb', line 38 belongs_to :door_type, optional: true |
#exterior_wall ⇒ ExteriorWall?
Validations:
36 |
# File 'app/models/door.rb', line 36 belongs_to :exterior_wall, optional: true |
#heat_loss_name ⇒ void
This method returns an undefined value.
65 66 67 68 69 70 71 |
# File 'app/models/door.rb', line 65 def heat_loss_name "Door: #{begin (exterior_wall.door_ids.index(id) + 1) rescue StandardError 'New' end} (Wall #{room_configuration.exterior_wall_ids.index(exterior_wall.id) + 1})" end |
#name ⇒ void
This method returns an undefined value.
56 57 58 59 60 61 62 |
# File 'app/models/door.rb', line 56 def name "Door: #{begin (exterior_wall.door_ids.index(id) + 1) rescue StandardError 'New' end}" end |
#room_configuration ⇒ Object
Alias for Exterior_wall#room_configuration
53 |
# File 'app/models/door.rb', line 53 delegate :room_configuration, to: :exterior_wall |
#set_door_insulation_type ⇒ void (protected)
This method returns an undefined value.
76 77 78 79 80 |
# File 'app/models/door.rb', line 76 def set_door_insulation_type # puts "set_door_insulation_type: self.door_type_id: #{self.door_type_id} self.door_core_type_id: #{self.door_core_type_id} self.door_frame_type_id: #{self.door_frame_type_id}" self.door_insulation_type = DoorInsulationType.where(door_type_id: door_type_id).where(door_core_type_id: door_core_type_id).where(door_frame_type_id: door_frame_type_id).first if door_core_type_id.present? && door_frame_type_id.present? # puts "set_door_insulation_type: self.door_insulation_type_id: #{self.door_insulation_type_id}" end |