Class: NewsFetcher::Commands::Get
- Inherits:
-
NewsFetcher::Command
- Object
- Simple::CommandParser::Command
- NewsFetcher::Command
- NewsFetcher::Commands::Get
- Defined in:
- lib/newsfetcher/commands/get.rb
Instance Attribute Summary
Attributes inherited from NewsFetcher::Command
#dir, #log_level, #max_threads
Instance Method Summary collapse
Instance Method Details
#run(args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/newsfetcher/commands/get.rb', line 7 def run(args) super args.each do |uri| fetcher = Fetcher.get(uri) if fetcher.success? feed = fetcher.parse_feed puts puts "URI: #{uri}" puts "Title: #{feed[:title]}" puts "Items:" feed[:items].each do |item| item.print puts end else warn "#{uri}: HTTP error #{fetcher.response_status} (#{fetcher.response_reason})" end end end |