Skip to content

Commit

Permalink
Present AirPollutionPrediction#overall_label in sentence case
Browse files Browse the repository at this point in the history
  • Loading branch information
edavey committed Oct 3, 2024
1 parent fd29de9 commit 4d661ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions app/models/air_pollution_prediction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class AirPollutionPrediction
:particulate_matter_10,
:particulate_matter_2_5,
:ozone,
:overall_score,
:overall_label
:overall_score

def initialize(
forecasted_at:,
Expand All @@ -25,6 +24,10 @@ def initialize(
@overall_label = overall_label
end

def overall_label
ActiveSupport::Inflector.upcase_first(@overall_label.downcase)
end

def inspect
attr_values = [
"@forecasted_at=#{forecasted_at}",
Expand All @@ -33,7 +36,7 @@ def inspect
"@particulate_matter_2_5=#{particulate_matter_2_5}",
"@ozone=#{ozone}",
"@overall_score=#{overall_score}",
"@overall_label=#{overall_label}"
"@overall_label=#{@overall_label}"
]

"#<#{self.class.name} #{attr_values.join(" ")}>"
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/forecast_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"temp_max" => 16.6,
"temp_min" => 10.0,
"total" => 2,
"total_status" => "LOW",
"total_status" => "VERY HIGH",
"uv" => 2,
"wind_am" => 4.9,
"wind_pm" => 5.3}
Expand Down Expand Up @@ -52,7 +52,7 @@
expect(forecast.air_pollution.particulate_matter_2_5).to eq(1)
expect(forecast.air_pollution.ozone).to eq(2)
expect(forecast.air_pollution.overall_score).to eq(2)
expect(forecast.air_pollution.overall_label).to eq("LOW")
expect(forecast.air_pollution.overall_label).to eq("Very high")

expect(forecast.uv).to eq(2)
expect(forecast.pollen).to eq(-999)
Expand Down

0 comments on commit 4d661ec

Please sign in to comment.