Class: ExampleInstallation
- Inherits:
-
Object
- Object
- ExampleInstallation
- Includes:
- ActiveModel::Serialization
- Defined in:
- app/models/example_installation.rb
Overview
Read-only projection of a RoomConfiguration that exposes the
customer-facing fields shown on the "Example Installations" carousel
on landing pages — price, coverage, wattage, voltage, operating cost,
and room type — without leaking the internals of the underlying room.
Instance Method Summary collapse
- #coverage ⇒ Integer
- #image ⇒ nil
-
#initialize(room_configuration) ⇒ ExampleInstallation
constructor
A new instance of ExampleInstallation.
- #operating_cost ⇒ Integer
- #price ⇒ Float
- #room_type_name ⇒ String
- #voltage ⇒ Integer
- #wattage ⇒ Integer
Constructor Details
#initialize(room_configuration) ⇒ ExampleInstallation
Returns a new instance of ExampleInstallation.
10 11 12 |
# File 'app/models/example_installation.rb', line 10 def initialize(room_configuration) @room_configuration = room_configuration end |
Instance Method Details
#coverage ⇒ Integer
26 27 28 |
# File 'app/models/example_installation.rb', line 26 def coverage @room_configuration.coverage_percentage || 100 # need some number here end |
#image ⇒ nil
15 16 17 18 |
# File 'app/models/example_installation.rb', line 15 def image # Plan images can be served directly from the room configuration using send_file. Discontinuing vignette plan images # room_configuration.vignette_plan_image end |
#operating_cost ⇒ Integer
41 42 43 |
# File 'app/models/example_installation.rb', line 41 def @room_configuration. end |
#price ⇒ Float
21 22 23 |
# File 'app/models/example_installation.rb', line 21 def price @room_configuration.total.to_f.round(2) end |
#room_type_name ⇒ String
46 47 48 |
# File 'app/models/example_installation.rb', line 46 def room_type_name @room_configuration.room_type.name end |
#voltage ⇒ Integer
36 37 38 |
# File 'app/models/example_installation.rb', line 36 def voltage @room_configuration.control_voltage || @room_configuration.line_items.heating_elements.first.item.voltage # need some number here end |
#wattage ⇒ Integer
31 32 33 |
# File 'app/models/example_installation.rb', line 31 def wattage @room_configuration.calculate_total_watts end |