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

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

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 Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#lengthObject (readonly)



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

validates :length, :width, presence: true

#widthObject (readonly)



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

validates :length, :width, presence: true

Instance Method Details

#areaObject



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_labelObject



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_rawObject



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

#nameObject



68
69
70
# File 'app/models/zone.rb', line 68

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

#room_configurationRoomConfiguration

Returns:

  • (RoomConfiguration)

See Also:



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

belongs_to :room_configuration

#sqftObject



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

def sqft
  width.to_f * length.to_f
end

#width_rawObject



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