Class: Cinch::Plugins::Weatherman::Forecast

Inherits:
Object
  • Object
show all
Defined in:
lib/cinch/plugins/weatherman/forecast.rb

Overview

Class to manage information on future conditions

Instance Method Summary collapse

Constructor Details

#initialize(location) ⇒ Forecast

Returns a new instance of Forecast.



7
8
9
10
11
12
13
14
15
16
# File 'lib/cinch/plugins/weatherman/forecast.rb', line 7

def initialize(location)
  @data = WeatherUnderground::Base.new.SimpleForecast(location).days[1]

  fail ArgumentError if @data.nil?

  @location = Weather.new(location).location
  @forecast = @data.conditions.downcase
  @temp_high = @data.high.fahrenheit.round
  @temp_low = @data.low.fahrenheit.round
end

Instance Method Details

#appendObject



23
24
25
# File 'lib/cinch/plugins/weatherman/forecast.rb', line 23

def append
  to_s.gsub(" in #{@location}", '')
end

#to_sObject



18
19
20
21
# File 'lib/cinch/plugins/weatherman/forecast.rb', line 18

def to_s
  "Tommorrow in #{@location}; #{@forecast}, " \
  "high of #{@temp_high}F, low of #{@temp_low}F."
end