Class: Www::SnowMeltingCalculatorComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Www::SnowMeltingCalculatorComponent
- Defined in:
- app/components/www/snow_melting_calculator_component.rb
Overview
Snow Melting Operating Cost Calculator
Calculates estimated operating costs based on coverage type, dimensions, runtime, and electricity rates
Constant Summary collapse
- WATTS_PER_SQFT =
Snow melting systems use 50W per square foot
50- DEFAULT_KWH_CENTS =
Default kwh cents.
16.26- TRANSLATIONS =
Translations.
{ en: { title: 'Operating Cost Calculator for Snow Melting', driveway_size: 'Driveway Size', single_car: 'Single Car Driveway (10 ft. wide)', double_car: 'Double Car Driveway (20 ft. wide)', triple_car: 'Triple Car Driveway (30 ft. wide)', custom: 'Custom Size', coverage_type: 'Coverage Type', full_coverage: 'Full Coverage — Heat the entire driveway', tire_tracks: 'Tire Tracks — Only heat paths for your car(s)', dimensions: 'Dimensions', width: 'Width', length: 'Length', tracks: '# Tracks', number_of_tracks: '# of Tracks', width_ft: 'Width (ft.)', length_ft: 'Length (ft.)', ft: 'ft.', zip_postal_code: 'Zip/Postal Code', my_location: 'Use my location', cents_per_kwh: 'Rate (¢/kWh)', snowfall_duration: 'Snowfall Duration', hour: 'hour', hours: 'hours', estimated_cost: 'Estimated Cost', per_hour: 'per hour', total_runtime: 'for runtime', rae_quote: 'A snow melting system is the ultimate set-it-and-forget-it solution. No more shoveling, no more slipping—just safe, clear walkways and driveways whenever you need them!' }, es: { title: 'Calculadora de Costo Operativo para Derretimiento de Nieve', driveway_size: 'Tamaño del Camino', single_car: 'Entrada de Un Auto (10 pies de ancho)', double_car: 'Entrada de Dos Autos (20 pies de ancho)', triple_car: 'Entrada de Tres Autos (30 pies de ancho)', custom: 'Tamaño Personalizado', coverage_type: 'Tipo de Cobertura', full_coverage: 'Cobertura Total — Calentar toda la entrada', tire_tracks: 'Huellas de Llantas — Solo calentar caminos para su(s) auto(s)', dimensions: 'Dimensiones', width: 'Ancho', length: 'Largo', tracks: '# Huellas', number_of_tracks: '# de Huellas', width_ft: 'Ancho (pies)', length_ft: 'Largo (pies)', ft: 'pies', zip_postal_code: 'Código Postal', my_location: 'Usar mi ubicación', cents_per_kwh: 'Tarifa (¢/kWh)', snowfall_duration: 'Duración de Nevada', hour: 'hora', hours: 'horas', estimated_cost: 'Costo Estimado', per_hour: 'por hora', total_runtime: 'por duración', rae_quote: 'Un sistema de derretimiento de nieve es la solución definitiva de configurar y olvidar. ¡Sin palear, sin resbalones—solo caminos seguros y despejados cuando los necesitas!' } }.freeze
- DRIVEWAY_SIZES =
Driveway sizes.
[ { id: 'single', tracks: 2, width: 10, length: 20, label_key: :single_car }, { id: 'double', tracks: 4, width: 20, length: 20, label_key: :double_car }, { id: 'triple', tracks: 6, width: 30, length: 20, label_key: :triple_car }, { id: 'custom', tracks: nil, width: nil, length: nil, label_key: :custom } ].freeze
Instance Attribute Summary collapse
-
#sp_area_name ⇒ Object
readonly
Returns the value of attribute sp_area_name.
-
#sp_project_link ⇒ Object
readonly
Returns the value of attribute sp_project_link.
Instance Method Summary collapse
- #calculate_default_kwh ⇒ Object
- #currency_symbol ⇒ Object
- #driveway_sizes ⇒ Object
- #horizontal? ⇒ Boolean
-
#initial_hourly_cost ⇒ Object
Calculate initial cost for server-side rendering.
- #initial_total_cost ⇒ Object
-
#initialize(locale: :en, default_width: 10, default_length: 20, default_tracks: 2, default_hours: 6, default_kwh: nil, default_coverage: :tire_tracks, layout: :vertical, smartplan: nil) ⇒ SnowMeltingCalculatorComponent
constructor
A new instance of SnowMeltingCalculatorComponent.
- #smartplan? ⇒ Boolean
- #sp_app_type ⇒ Object
- #sp_carousel_options ⇒ Object
- #sp_icon ⇒ Object
- #sp_link ⇒ Object
- #sp_rae_avatar ⇒ Object
- #sp_rae_quote ⇒ Object
- #sp_slides ⇒ Object
- #sp_title ⇒ Object
- #t(key) ⇒ Object
- #tire_tracks_default? ⇒ Boolean
Methods inherited from ApplicationComponent
#cms_link, #fetch_or_fallback, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags
Constructor Details
#initialize(locale: :en, default_width: 10, default_length: 20, default_tracks: 2, default_hours: 6, default_kwh: nil, default_coverage: :tire_tracks, layout: :vertical, smartplan: nil) ⇒ SnowMeltingCalculatorComponent
Returns a new instance of SnowMeltingCalculatorComponent.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 98 def initialize( locale: :en, default_width: 10, default_length: 20, default_tracks: 2, default_hours: 6, default_kwh: nil, default_coverage: :tire_tracks, layout: :vertical, smartplan: nil ) super() @locale = locale.to_sym @default_width = default_width @default_length = default_length @default_tracks = default_tracks @default_hours = default_hours @default_kwh = default_kwh || calculate_default_kwh @default_coverage = default_coverage @layout = layout.to_sym @smartplan = smartplan resolve_smartplan_config if @smartplan end |
Instance Attribute Details
#sp_area_name ⇒ Object (readonly)
Returns the value of attribute sp_area_name.
137 138 139 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 137 def sp_area_name @sp_area_name end |
#sp_project_link ⇒ Object (readonly)
Returns the value of attribute sp_project_link.
137 138 139 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 137 def sp_project_link @sp_project_link end |
Instance Method Details
#calculate_default_kwh ⇒ Object
144 145 146 147 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 144 def calculate_default_kwh rate = ElectricityRate.get_average_rate_for_locale(@locale) rate ? (rate * 100).round(2) : DEFAULT_KWH_CENTS end |
#currency_symbol ⇒ Object
173 174 175 176 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 173 def currency_symbol symbol = helpers.canada? ? 'C$' : '$' %(<span style="font-size:.55em;vertical-align:baseline;position:relative;top:-.45em;font-weight:500;color:#6c757d">#{symbol}</span>).html_safe end |
#driveway_sizes ⇒ Object
157 158 159 160 161 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 157 def driveway_sizes DRIVEWAY_SIZES.map do |size| size.merge(name: t(size[:label_key])) end end |
#horizontal? ⇒ Boolean
122 123 124 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 122 def horizontal? @layout == :horizontal end |
#initial_hourly_cost ⇒ Object
Calculate initial cost for server-side rendering
164 165 166 167 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 164 def initial_hourly_cost sqft = calculate_sqft calculate_hourly_cost(sqft, @default_kwh) end |
#initial_total_cost ⇒ Object
169 170 171 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 169 def initial_total_cost initial_hourly_cost * @default_hours end |
#smartplan? ⇒ Boolean
126 127 128 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 126 def smartplan? @smartplan.present? end |
#sp_app_type ⇒ Object
132 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 132 def sp_app_type = @sp_config&.dig(:application_type) |
#sp_carousel_options ⇒ Object
139 140 141 142 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 139 def { type: 'fade', perPage: 1, perMove: 1, arrows: true, pagination: true, autoplay: true, interval: 4000, pauseOnHover: true, rewind: true, speed: 600 } end |
#sp_icon ⇒ Object
131 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 131 def sp_icon = @sp_config&.dig(:icon) |
#sp_link ⇒ Object
133 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 133 def sp_link = @sp_config&.dig(:smartplan_link) |
#sp_rae_avatar ⇒ Object
134 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 134 def sp_rae_avatar = @sp_config&.dig(:rae_avatar) |
#sp_rae_quote ⇒ Object
135 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 135 def sp_rae_quote = @sp_config&.dig(:rae_quote) |
#sp_slides ⇒ Object
136 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 136 def = @sp_config&.dig(:carousel_slides) || [] |
#sp_title ⇒ Object
130 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 130 def sp_title = @sp_config&.dig(:title) |
#t(key) ⇒ Object
149 150 151 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 149 def t(key) TRANSLATIONS.dig(@locale, key) || TRANSLATIONS.dig(:en, key) || key.to_s.humanize end |
#tire_tracks_default? ⇒ Boolean
153 154 155 |
# File 'app/components/www/snow_melting_calculator_component.rb', line 153 def tire_tracks_default? @default_coverage == :tire_tracks end |