class Sport
Lists the latest BBC Sport
headlines
Public Class Methods
new(io = STDOUT)
click to toggle source
# File lib/bbc/sport.rb, line 8 def initialize(io = STDOUT) @io = io end
Public Instance Methods
headlines()
click to toggle source
# File lib/bbc/sport.rb, line 12 def headlines data['entries'].each do |item| prompt = yellow item['prompt'].capitalize.ljust(22) headline = item['headline'] @io.puts prompt + headline end end
Private Instance Methods
data()
click to toggle source
# File lib/bbc/sport.rb, line 27 def data begin raw = open(url, 'UserAgent' => AUNTIE::USER_AGENT).read JSON.parse(raw) rescue raise 'Unable to download sport data' end end
url()
click to toggle source
# File lib/bbc/sport.rb, line 23 def url 'http://polling.bbc.co.uk/sport/0/16189337/ticker.sjson' end