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
Constants included
from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
#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
config
#after_commit
#publish_event
Instance Attribute Details
#length ⇒ Object
23
|
# File 'app/models/zone.rb', line 23
validates :length, :width, presence: true
|
#width ⇒ Object
23
|
# File 'app/models/zone.rb', line 23
validates :length, :width, presence: true
|
Instance Method Details
#area ⇒ Object
62
63
64
65
66
|
# File 'app/models/zone.rb', line 62
def area
(RubyUnits::Unit.new(width) * RubyUnits::Unit.new(length)).to_s("%0.2f")
rescue StandardError
'n/a'
end
|
#dimension_label ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'app/models/zone.rb', line 28
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 ⇒ Object
56
57
58
59
60
|
# File 'app/models/zone.rb', line 56
def length_raw
RubyUnits::Unit.new(length)
rescue StandardError
''
end
|
#length_raw=(measurement) ⇒ Object
52
53
54
|
# File 'app/models/zone.rb', line 52
def length_raw=(measurement)
self.length = measurement
end
|
#name ⇒ Object
68
69
70
|
# File 'app/models/zone.rb', line 68
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 ⇒ Object
38
39
40
|
# File 'app/models/zone.rb', line 38
def sqft
width.to_f * length.to_f
end
|
#width_raw ⇒ Object
46
47
48
49
50
|
# File 'app/models/zone.rb', line 46
def width_raw
RubyUnits::Unit.new(width)
rescue StandardError
''
end
|
#width_raw=(measurement) ⇒ Object
42
43
44
|
# File 'app/models/zone.rb', line 42
def width_raw=(measurement)
self.width = measurement
end
|