Class: Zone
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
Models::Auditable::ALWAYS_IGNORED
#creator, #updater
Instance Method Summary
collapse
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
#publish_event
Instance Method Details
#area ⇒ Object
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_label ⇒ Object
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_raw ⇒ Object
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
|
#name ⇒ Object
64
65
66
|
# File 'app/models/zone.rb', line 64
def name
"Heated Area (LxW) #{self.dimension_label}, #{self.area}"
end
|
#room_configuration ⇒ RoomConfiguration
20
|
# File 'app/models/zone.rb', line 20
belongs_to :room_configuration
|
#sqft ⇒ Object
37
38
39
|
# File 'app/models/zone.rb', line 37
def sqft
self.width.to_f * self.length.to_f
end
|
#width_raw ⇒ Object
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
|