Class: FloorType

Inherits:
ApplicationRecord show all
Defined in:
app/models/floor_type.rb

Overview

== Schema Information

Table name: floor_types
Database name: primary

id :integer not null, primary key
design_tool_name :string(255)
environment :string(50)
ev2_inset :integer
is_active :boolean default(TRUE), not null
name :string(80) not null
product :string(12) not null
seo_key :string

Indexes

index_floor_types_on_name (name)
index_floor_types_on_seo_key (seo_key)

Constant Summary

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Has and belongs to many collapse

Has many collapse

Class Method Summary collapse

Instance Method Summary collapse

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

Class Method Details

.activeActiveRecord::Relation<FloorType>

A relation of FloorTypes that are active. Active Record Scope

Returns:

See Also:



49
# File 'app/models/floor_type.rb', line 49

scope :active, -> { where(is_active: true).by_name }

.by_environmentActiveRecord::Relation<FloorType>

A relation of FloorTypes that are by environment. Active Record Scope

Returns:

See Also:



50
# File 'app/models/floor_type.rb', line 50

scope :by_environment, ->(ev) { where(environment: ev).by_name }

.by_nameActiveRecord::Relation<FloorType>

A relation of FloorTypes that are by name. Active Record Scope

Returns:

See Also:



48
# File 'app/models/floor_type.rb', line 48

scope :by_name, -> { order("floor_types.name") }

.floatingActiveRecord::Relation<FloorType>

A relation of FloorTypes that are floating. Active Record Scope

Returns:

See Also:



51
# File 'app/models/floor_type.rb', line 51

scope :floating, -> { where("floor_types.name ILIKE '%floating%'") }

.indoorActiveRecord::Relation<FloorType>

A relation of FloorTypes that are indoor. Active Record Scope

Returns:

See Also:



54
# File 'app/models/floor_type.rb', line 54

scope :indoor, -> { by_environment('Indoor') }

.indoorsActiveRecord::Relation<FloorType>

A relation of FloorTypes that are indoors. Active Record Scope

Returns:

See Also:



52
# File 'app/models/floor_type.rb', line 52

scope :indoors, -> { by_environment('Indoor') }

.options_for_select(zev = false, store_id = 1) ⇒ Object



61
62
63
64
65
66
67
68
# File 'app/models/floor_type.rb', line 61

def self.options_for_select(zev = false, store_id = 1)
  options = if zev.present?
              active.by_environment(zev)
            else
              active
            end
  options.select { |ft| ft.store_ids.include?(store_id) }.map { |f| [f.name.to_s, f.id] }
end

.outdoorActiveRecord::Relation<FloorType>

A relation of FloorTypes that are outdoor. Active Record Scope

Returns:

See Also:



55
# File 'app/models/floor_type.rb', line 55

scope :outdoor, -> { by_environment('Outdoor') }

.outdoorsActiveRecord::Relation<FloorType>

A relation of FloorTypes that are outdoors. Active Record Scope

Returns:

See Also:



53
# File 'app/models/floor_type.rb', line 53

scope :outdoors, -> { by_environment('Outdoor') }

Instance Method Details

#adjust_area_factorObject



102
103
104
105
106
107
108
# File 'app/models/floor_type.rb', line 102

def adjust_area_factor
  factor = 1.0
  # take into account nailed surfaces with sleepers, reducing area by 10%
  factor = 0.9 if is_nailed?
  # puts "floor_type.adjust_area_factor: self.is_nailed?: #{self.is_nailed?}, factor: #{factor}"
  factor
end

#heating_element_product_line_optionsActiveRecord::Relation<HeatingElementProductLineOption>

Returns:

See Also:



45
# File 'app/models/floor_type.rb', line 45

has_many :heating_element_product_line_options, inverse_of: :floor_type

#is_carpet?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'app/models/floor_type.rb', line 74

def is_carpet?
  name.to_s.downcase.index('carpet').present?
end

#is_copper?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'app/models/floor_type.rb', line 119

def is_copper?
  name.downcase.index("copper").present?
end

#is_engineered?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'app/models/floor_type.rb', line 82

def is_engineered?
  name.to_s.downcase.index('engineered').present?
end

#is_floating?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'app/models/floor_type.rb', line 70

def is_floating?
  name.to_s.downcase.index('float').present?
end

#is_indoors?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'app/models/floor_type.rb', line 94

def is_indoors?
  environment.to_s.downcase.index('indoor').present?
end

#is_laminate?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'app/models/floor_type.rb', line 78

def is_laminate?
  name.to_s.downcase.index('laminate').present?
end

#is_nailed?Boolean

Returns:

  • (Boolean)


110
111
112
113
# File 'app/models/floor_type.rb', line 110

def is_nailed?
  # puts "floor_type.is_nailed: self.name: #{self.name}, is_nailed?: #{self.name.downcase =~ /^nailed/}"
  name.downcase.index("nailed").present?
end

#is_outdoors?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'app/models/floor_type.rb', line 98

def is_outdoors?
  environment.to_s.downcase.index('outdoor').present?
end

#is_slate_shingle?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'app/models/floor_type.rb', line 115

def is_slate_shingle?
  name.downcase.index("slate shingle").present?
end

#is_temperature_limited?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'app/models/floor_type.rb', line 90

def is_temperature_limited?
  is_carpet? or is_laminate? or is_engineered? or is_vinyl?
end

#is_vinyl?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'app/models/floor_type.rb', line 86

def is_vinyl?
  name.to_s.downcase.index('vinyl').present?
end

#is_wood_shake?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'app/models/floor_type.rb', line 123

def is_wood_shake?
  name.downcase.index("wood shake").present?
end

#require_expansion_joint?(room_type_id = nil) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/models/floor_type.rb', line 57

def require_expansion_joint?(room_type_id = nil)
  HeatingElementProductLineOption.get_field_array_from_options(:require_expansion_joint, { floor_type_id: id, room_type_id: room_type_id }).first
end

#room_configurationsActiveRecord::Relation<RoomConfiguration>

Returns:

  • (ActiveRecord::Relation<RoomConfiguration>)

See Also:



43
# File 'app/models/floor_type.rb', line 43

has_many :room_configurations

#showcasesActiveRecord::Relation<Showcase>

Returns:

See Also:



44
# File 'app/models/floor_type.rb', line 44

has_many :showcases

#storesActiveRecord::Relation<Store>

Returns:

  • (ActiveRecord::Relation<Store>)

See Also:



42
# File 'app/models/floor_type.rb', line 42

has_and_belongs_to_many :stores

#sub_floor_typesActiveRecord::Relation<SubFloorType>

Returns:

See Also:



46
# File 'app/models/floor_type.rb', line 46

has_many :sub_floor_types, through: :heating_element_product_line_options