samaaron / defining-pi

MIT License
3 stars 0 forks source link

feed URL text #47

Closed choo2053 closed 11 years ago

choo2053 commented 11 years ago

Same issue: it is not working, the canvas remains blank....

I have typed....: a = feed_text "http://open.live.bbc.co.uk/weather/feeds/en/7114227/observations.rss"

a.each do |i| text rand(100), rand(100), i sleep 2 end

Sonic Pi responds....: undefined method `each' for #String:0xc7ae20

Connection initiated...

R-Pi's terminal responds:

127.0.0.1 - - [15/Oct/2013 21:22:27] "GET /favicon.ico HTTP/1.1" 404 448 0.2192 127.0.0.1 - - [15/Oct/2013 21:22:27] "GET /favicon.ico HTTP/1.1" 404 448 0.0654 127.0.0.1 - - [15/Oct/2013 21:22:28] "GET /favicon.ico HTTP/1.1" 404 448 0.0384 127.0.0.1 - - [15/Oct/2013 21:27:58] "GET / HTTP/1.1" 200 1131 0.2409 127.0.0.1 - - [15/Oct/2013 21:27:58] "GET /vendor/codemirror/lib/codemirror.css HTTP/1.1" 200 - 0.3822 127.0.0.1 - - [15/Oct/2013 21:27:58] "GET /vendor/codemirror/lib/codemirror.js HTTP/1.1" 200 - 0.1761 127.0.0.1 - - [15/Oct/2013 21:27:58] "GET /vendor/codemirror/addon/edit/matchbrackets.js HTTP/1.1" 200 - 0.1304 127.0.0.1 - - [15/Oct/2013 21:27:58] "GET /vendor/codemirror/mode/ruby/ruby.js HTTP/1.1" 200 - 0.1280 127.0.0.1 - - [15/Oct/2013 21:27:59] "GET /vendor/kinetic-v4.7.2.min.js HTTP/1.1" 200 - 0.1262 127.0.0.1 - - [15/Oct/2013 21:27:59] "GET /vendor/bootstrap/css/bootstrap.css HTTP/1.1" 200 - 0.1279 127.0.0.1 - - [15/Oct/2013 21:27:59] "GET /js/init_editor.js HTTP/1.1" 200 - 0.0397 127.0.0.1 - - [15/Oct/2013 21:27:59] "GET /js/cljs-main.js HTTP/1.1" 200 - 0.1755 127.0.0.1 - - [15/Oct/2013 21:28:09] "GET /favicon.ico HTTP/1.1" 404 448 0.0905 127.0.0.1 - - [15/Oct/2013 21:28:09] "GET /favicon.ico HTTP/1.1" 404 448 0.0997 /var/lib/gems/1.9.1/gems/simple-rss-1.2.3/lib/simple-rss.rb:155: warning: regexp match /.../n against to UTF-8 string /var/lib/gems/1.9.1/gems/simple-rss-1.2.3/lib/simple-rss.rb:155: warning: regexp match /.../n against to UTF-8 string

Do you have an example of command line plus URL that worked with you, be it for text or entries?

thanks in advance Chooc Ly

samaaron commented 11 years ago

Hi Chooc,

your problem is that you're trying to iterate over a string rather than a list. feed_text returns a string representing all the text of the feed, and feed_entries returns a list of string for each entry.

If you replace feed_text with feed_entries in your code, it will work. However, be aware that that particular feed currently only has one entry :-)

choo2053 commented 11 years ago

wicked! I've just entered the Cambodian forecast, it does work. Thanks a million