Class: Zone

Inherits:
ApplicationRecord show all
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

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

Instance Method Summary collapse

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

#publish_event

Instance Method Details

#areaObject



59
60
61
62
# File 'app/models/zone.rb', line 59

def area
  
  ((RubyUnits::Unit.new(self.width) * RubyUnits::Unit.new(self.length)).to_s("%0.2f")) rescue 'n/a'
end

#dimension_labelObject



27
28
29
30
31
32
33
34
35
# File 'app/models/zone.rb', line 27

def dimension_label
  if self.length and self.width
    "#{self.length_raw} x #{self.width_raw}"
  elsif self.length
    "#{self.length_raw}"
  elsif self.width
    "#{self.width_raw}"
  end
end

#length_rawObject



54
55
56
57
# File 'app/models/zone.rb', line 54

def length_raw
  
  RubyUnits::Unit.new(self.length) rescue ''
end

#length_raw=(measurement) ⇒ Object



50
51
52
# File 'app/models/zone.rb', line 50

def length_raw=(measurement)
  self.length = measurement
end

#nameObject



64
65
66
# File 'app/models/zone.rb', line 64

def name
  "Heated Area (LxW) #{self.dimension_label}, #{self.area}"
end

#room_configurationRoomConfiguration

Returns:

  • (RoomConfiguration)

See Also:



20
# File 'app/models/zone.rb', line 20

belongs_to  :room_configuration

#sqftObject



37
38
39
# File 'app/models/zone.rb', line 37

def sqft
  self.width.to_f * self.length.to_f
end

#width_rawObject



45
46
47
48
# File 'app/models/zone.rb', line 45

def width_raw
  
  RubyUnits::Unit.new(self.width) rescue ''
end

#width_raw=(measurement) ⇒ Object



41
42
43
# File 'app/models/zone.rb', line 41

def width_raw=(measurement)
  self.width = measurement
end