Class: Skylight
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Skylight
- Includes:
- Models::Auditable, Models::HeatLossable
- Defined in:
- app/models/skylight.rb
Overview
== Schema Information
Table name: skylights
Database name: primary
id :integer not null, primary key
area :float
user_u_value :float
ceiling_id :integer
skylight_frame_type_id :integer
skylight_glass_type_id :integer
skylight_insulation_type_id :integer
Indexes
skylights_ceiling_id_idx (ceiling_id)
skylights_skylight_frame_type_id_idx (skylight_frame_type_id)
skylights_skylight_glass_type_id_idx (skylight_glass_type_id)
skylights_skylight_insulation_type_id_idx (skylight_insulation_type_id)
Foreign Keys
skylights_ceiling_id_fk (ceiling_id => ceilings.id) ON DELETE => cascade
skylights_skylight_frame_type_id_fk (skylight_frame_type_id => skylight_frame_types.id)
skylights_skylight_glass_type_id_fk (skylight_glass_type_id => skylight_glass_types.id)
skylights_skylight_insulation_type_id_fk (skylight_insulation_type_id => skylight_insulation_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
Instance Attribute Summary collapse
- #area ⇒ Object readonly
Belongs to collapse
- #ceiling ⇒ Ceiling
- #skylight_frame_type ⇒ SkylightFrameType
- #skylight_glass_type ⇒ SkylightGlassType
- #skylight_insulation_type ⇒ SkylightInsulationType
Methods included from Models::Auditable
Delegated Instance Attributes collapse
-
#room_configuration ⇒ Object
Alias for Ceiling#room_configuration.
Instance Method Summary collapse
- #check_insulation_or_u_value ⇒ Object protected
- #check_sibling_areas_less_than_parent ⇒ Object protected
- #heat_loss_name ⇒ Object
- #name ⇒ Object
- #set_skylight_insulation_type ⇒ Object 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::EventPublishable
Instance Attribute Details
#area ⇒ Object (readonly)
46 |
# File 'app/models/skylight.rb', line 46 validates :area, :numericality => { :less_than_or_equal_to => 9999.9, :greater_than => 0.0 } |
Instance Method Details
#check_insulation_or_u_value ⇒ Object (protected)
74 75 76 77 78 79 80 81 |
# File 'app/models/skylight.rb', line 74 def check_insulation_or_u_value # puts "check_insulation_or_u_value: self.user_u_value: #{self.user_u_value} self.skylight_glass_type.name: #{self.skylight_glass_type.name rescue 'not defined'} self.skylight_frame_type.name: #{self.skylight_frame_type.name rescue 'not defined'} self.skylight_insulation_type.name: #{self.skylight_insulation_type.name rescue 'not defined'}" if self.user_u_value.blank? and (self.skylight_glass_type.nil? or self.skylight_frame_type.nil? or self.skylight_insulation_type.nil?) errors.add(:skylight_glass_type_id, "required AND") if self.skylight_glass_type.nil? errors.add(:skylight_frame_type_id, "required OR") errors.add(:user_u_value, "required") end end |
#check_sibling_areas_less_than_parent ⇒ Object (protected)
68 69 70 71 72 |
# File 'app/models/skylight.rb', line 68 def check_sibling_areas_less_than_parent if self.area and (self.area + self.ceiling.skylights.reject{|s| s.id == (self.id || -1)}.sum{|w| w.area}) >= self.ceiling.area errors.add(:area, "plus areas of other skylights can't exceed ceiling area") end end |
#heat_loss_name ⇒ Object
56 57 58 |
# File 'app/models/skylight.rb', line 56 def heat_loss_name self.name end |
#name ⇒ Object
52 53 54 |
# File 'app/models/skylight.rb', line 52 def name "Skylight: #{(self.ceiling.skylight_ids.index(self.id) + 1) rescue 'New'}" end |
#room_configuration ⇒ Object
Alias for Ceiling#room_configuration
50 |
# File 'app/models/skylight.rb', line 50 delegate :room_configuration, :to => :ceiling |
#set_skylight_insulation_type ⇒ Object (protected)
62 63 64 65 66 |
# File 'app/models/skylight.rb', line 62 def set_skylight_insulation_type # puts "set_skylight_insulation_type: self.skylight_glass_type_id: #{self.skylight_glass_type_id} self.skylight_frame_type_id: #{self.skylight_frame_type_id}" self.skylight_insulation_type = SkylightInsulationType.where(:skylight_glass_type_id => self.skylight_glass_type_id).where(:skylight_frame_type_id => self.skylight_frame_type_id).first if (self.skylight_glass_type_id.present? and self.skylight_frame_type_id.present?) # puts "set_skylight_insulation_type: self.skylight_insulation_type_id: #{self.skylight_insulation_type_id}" end |
#skylight_frame_type ⇒ SkylightFrameType
41 |
# File 'app/models/skylight.rb', line 41 belongs_to :skylight_frame_type, optional: true |
#skylight_glass_type ⇒ SkylightGlassType
40 |
# File 'app/models/skylight.rb', line 40 belongs_to :skylight_glass_type, optional: true |
#skylight_insulation_type ⇒ SkylightInsulationType
42 |
# File 'app/models/skylight.rb', line 42 belongs_to :skylight_insulation_type, optional: true |