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 Models::Schedulable

Models::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 Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#lengthString(10) (readonly)

Returns:

  • (String(10))

Validations:

  • Length ({ maximum: 10, message: "is too large" })


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

validates :length, presence: true

#widthString(10) (readonly)

Returns:

  • (String(10))

Validations:

  • Length ({ maximum: 10, message: "is too large" })


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

validates :width, presence: true

Instance Method Details

#areavoid

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_labelvoid

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_rawvoid

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

Parameters:

  • measurement (Object)
  • measurement (Object)

Returns:

  • (void)
  • (void)


66
67
68
# File 'app/models/zone.rb', line 66

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

#namevoid

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_configurationRoomConfiguration?

Returns:



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

belongs_to :room_configuration

#sqftvoid

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_rawvoid

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

Parameters:

  • measurement (Object)
  • measurement (Object)

Returns:

  • (void)
  • (void)


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

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