Class: Zone
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Zone
- Includes:
- Models::Auditable
- Defined in:
- app/models/zone.rb
Overview
== Schema Information
Table name: zones
Database name: primary
id :integer not null, primary key
length :string(10)
width :string(10)
created_at :datetime
updated_at :datetime
room_configuration_id :integer
Indexes
index_zones_on_room_configuration_id (room_configuration_id)
Constant Summary
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
- #length ⇒ String(10) readonly
- #width ⇒ String(10) readonly
Belongs to collapse
Methods included from Models::Auditable
Instance Method Summary collapse
- #area ⇒ void
- #dimension_label ⇒ void
- #length_raw ⇒ void
- #length_raw=(measurement) ⇒ void
- #name ⇒ void
- #sqft ⇒ void
- #width_raw ⇒ void
- #width_raw=(measurement) ⇒ void
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
#length ⇒ String(10) (readonly)
Validations:
- Length ({ maximum: 10, message: "is too large" })
24 |
# File 'app/models/zone.rb', line 24 validates :length, presence: true |
#width ⇒ String(10) (readonly)
Validations:
- Length ({ maximum: 10, message: "is too large" })
26 |
# File 'app/models/zone.rb', line 26 validates :width, presence: true |
Instance Method Details
#area ⇒ void
This method returns an undefined value.
78 79 80 81 82 |
# File 'app/models/zone.rb', line 78 def area (RubyUnits::Unit.new(width) * RubyUnits::Unit.new(length)).to_s("%0.2f") rescue StandardError 'n/a' end |
#dimension_label ⇒ void
This method returns an undefined value.
32 33 34 35 36 37 38 39 40 |
# File 'app/models/zone.rb', line 32 def dimension_label if length && width "#{length_raw} x #{width_raw}" elsif length length_raw.to_s elsif width width_raw.to_s end end |
#length_raw ⇒ void
This method returns an undefined value.
71 72 73 74 75 |
# File 'app/models/zone.rb', line 71 def length_raw RubyUnits::Unit.new(length) rescue StandardError '' end |
#length_raw=(measurement) ⇒ void
66 67 68 |
# File 'app/models/zone.rb', line 66 def length_raw=(measurement) self.length = measurement end |
#name ⇒ void
This method returns an undefined value.
85 86 87 |
# File 'app/models/zone.rb', line 85 def name "Heated Area (LxW) #{dimension_label}, #{area}" end |
#room_configuration ⇒ RoomConfiguration?
21 |
# File 'app/models/zone.rb', line 21 belongs_to :room_configuration |
#sqft ⇒ void
This method returns an undefined value.
43 44 45 |
# File 'app/models/zone.rb', line 43 def sqft width.to_f * length.to_f end |
#width_raw ⇒ void
This method returns an undefined value.
56 57 58 59 60 |
# File 'app/models/zone.rb', line 56 def width_raw RubyUnits::Unit.new(width) rescue StandardError '' end |
#width_raw=(measurement) ⇒ void
51 52 53 |
# File 'app/models/zone.rb', line 51 def width_raw=(measurement) self.width = measurement end |