ny_forecast 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ny_forecast.rb +12 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d698a69ff5a281305ff25c53c8e564948dc74d2
4
- data.tar.gz: 051747c2cc9cdba68e4203bfddf3c89bde193b8a
3
+ metadata.gz: 21bd6f5fcf423c740031fd2828cf8606b40e5970
4
+ data.tar.gz: 1ebc78ca27a0fc8d9512e0b52cc3cde7609b2210
5
5
  SHA512:
6
- metadata.gz: 966112307f3950449682e43d3192f247314eb1e6d33c0119a33ce3156696c53e99a9157cdb9e954bc698028f4703625c9cda42048de0abba33da263e9a879fa6
7
- data.tar.gz: 77a4b0bcca826cce1b97d4592470afab30e9daa595167cf5a85d3b4b84d99801e41f3f024628e3867801bfbff8a3e01081f684187745ade39cdefcc1bffa8b30
6
+ metadata.gz: 593b0e421493274c9b496a6dae0b85d933f6a0d97a1c79afc2f1f88efd01a59e81669264ce0251828f5df9478aa8f9c486db9529f992bd967a08b95f98509640
7
+ data.tar.gz: 2db6f55692992a3ef2efd7bdc2c6e4386a32659237010520b109c274af34aeab358626f171446835db302dd301be4aba12db7b8ce238a960044b9a642a5da32e
data/lib/ny_forecast.rb CHANGED
@@ -4,21 +4,26 @@ require 'open-uri'
4
4
  class NYForecast
5
5
  def initialize
6
6
  @doc = Nokogiri::HTML(open("http://www.weather.com/weather/hourbyhour/graph/New+York+NY+USNY0996:1:US"))
7
+ intro
7
8
  scrape_forecast
8
9
  end
9
10
 
11
+ def intro
12
+ introduction = "\nToday's date: #{Date.today}.\nThe weather for the next six hours is as follows:\n\n"
13
+ puts introduction
14
+ end
10
15
 
11
16
  def scrape_forecast
12
-
13
-
17
+ to_delete = @doc.css("span.wx-date-label").collect {|x| x.text} + @doc.css("span.wx-day-label").collect {|x| x.text}
18
+
14
19
  forecasts = @doc.css("div.wx-timepart").collect { |section| section.text.gsub(/\n/,'') }
20
+
15
21
  forecasts.each_with_index do |forecast, i|
16
- if i % 4 == 0
17
- puts forecast.gsub("AM","AM\n").gsub("PM","PM\n").gsub("FEE", "\nFEE").gsub("°", "°\n").gsub("%", "%\n").gsub("Show 15 Minute Details","").gsub("mph","mph\n\n")
22
+ to_delete.each do |word|
23
+ forecast.gsub!("#{word}", "")
18
24
  end
19
- end
20
25
 
21
-
26
+ puts forecast.gsub("°F", "°").gsub("AM","AM\n").gsub("PM","PM\n").gsub("FEE", "\nFEE").gsub("°", "°\n").gsub("%", "%\n").gsub("Show 15 Minute Details","").gsub("mph","mph\n\n") if i % 4 == 0
27
+ end
22
28
  end
23
-
24
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ny_forecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Kohlbrenner