Class: Window
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Window
- Includes:
- Models::Auditable, Models::HeatLossable
- Defined in:
- app/models/window.rb
Overview
== Schema Information
Table name: windows
Database name: primary
id :integer not null, primary key
area :float
user_u_value :float
exterior_wall_id :integer
window_frame_type_id :integer
window_glass_type_id :integer
window_insulation_type_id :integer
window_type_id :integer
Indexes
windows_exterior_wall_id_idx (exterior_wall_id)
windows_window_frame_type_id_idx (window_frame_type_id)
windows_window_glass_type_id_idx (window_glass_type_id)
windows_window_insulation_type_id_idx (window_insulation_type_id)
windows_window_type_id_idx (window_type_id)
Foreign Keys
windows_exterior_wall_id_fk (exterior_wall_id => exterior_walls.id) ON DELETE => cascade
windows_window_frame_type_id_fk (window_frame_type_id => window_frame_types.id)
windows_window_glass_type_id_fk (window_glass_type_id => window_glass_types.id)
windows_window_insulation_type_id_fk (window_insulation_type_id => window_insulation_types.id)
windows_window_type_id_fk (window_type_id => window_types.id)
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::Auditable
Models::Auditable::ALWAYS_IGNORED
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
- #area ⇒ Float readonly
Belongs to collapse
- #exterior_wall ⇒ ExteriorWall
- #window_frame_type ⇒ WindowFrameType?
- #window_glass_type ⇒ WindowGlassType?
- #window_insulation_type ⇒ WindowInsulationType?
- #window_type ⇒ WindowType?
Methods included from Models::Auditable
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 ⇒ String
- #name ⇒ String
- #set_window_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 included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
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)
58 |
# File 'app/models/window.rb', line 58 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.
100 101 102 103 104 105 |
# File 'app/models/window.rb', line 100 def check_insulation_or_u_value return unless user_u_value.blank? && (window_type.nil? || window_glass_type.nil? || window_frame_type.nil? || window_insulation_type.nil?) errors.add(:window_type_id, ", glass, 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.
95 96 97 |
# File 'app/models/window.rb', line 95 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.reject { |w| w.id == (id || -1) }.sum(&:area) + exterior_wall.doors.to_a.sum(&:area)) >= exterior_wall.area) end |
#exterior_wall ⇒ ExteriorWall
44 |
# File 'app/models/window.rb', line 44 belongs_to :exterior_wall, optional: true |
#heat_loss_name ⇒ String
74 75 76 77 78 79 80 |
# File 'app/models/window.rb', line 74 def heat_loss_name "Window: #{begin (exterior_wall.window_ids.index(id) + 1) rescue StandardError 'New' end} (Wall #{room_configuration.exterior_wall_ids.index(exterior_wall.id) + 1})" end |
#name ⇒ String
65 66 67 68 69 70 71 |
# File 'app/models/window.rb', line 65 def name "Window: #{begin (exterior_wall.window_ids.index(id) + 1) rescue StandardError 'New' end}" end |
#room_configuration ⇒ Object
Alias for Exterior_wall#room_configuration
62 |
# File 'app/models/window.rb', line 62 delegate :room_configuration, to: :exterior_wall |
#set_window_insulation_type ⇒ void (protected)
This method returns an undefined value.
85 86 87 88 89 90 91 92 |
# File 'app/models/window.rb', line 85 def set_window_insulation_type # puts "set_window_insulation_type: self.window_type_id: #{self.window_type_id} self.window_glass_type_id: #{self.window_glass_type_id} self.window_frame_type_id: #{self.window_frame_type_id}" return unless window_glass_type_id.present? && window_frame_type_id.present? self.window_insulation_type = WindowInsulationType.where(window_type_id: window_type_id).where(window_glass_type_id: window_glass_type_id).where(window_frame_type_id: window_frame_type_id).first # puts "set_window_insulation_type: self.window_insulation_type_id: #{self.window_insulation_type_id}" end |
#window_frame_type ⇒ WindowFrameType?
50 |
# File 'app/models/window.rb', line 50 belongs_to :window_frame_type, optional: true |
#window_glass_type ⇒ WindowGlassType?
48 |
# File 'app/models/window.rb', line 48 belongs_to :window_glass_type, optional: true |
#window_insulation_type ⇒ WindowInsulationType?
52 |
# File 'app/models/window.rb', line 52 belongs_to :window_insulation_type, optional: true |
#window_type ⇒ WindowType?
46 |
# File 'app/models/window.rb', line 46 belongs_to :window_type, optional: true |