Class: Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/cli.rb

Instance Method Summary collapse

Instance Method Details

#__print_versionObject


15
16
17
# File 'lib/cli.rb', line 15

def __print_version
  puts version
end

#add(url) ⇒ Object


22
23
24
25
26
27
28
29
# File 'lib/cli.rb', line 22

def add(url)
  unless valid_url?(url)
    puts 'Invalid URL'
    return
  end

  LideoController.new.add(url, group(options))
end

#feedsObject


57
58
59
60
61
62
63
64
# File 'lib/cli.rb', line 57

def feeds
  url_to_remove = from_r_option(options)
  if url_to_remove.nil?
    list_feeds
  else
    remove_feed(url_to_remove)
  end
end

#fetchObject


45
46
47
48
49
50
51
52
# File 'lib/cli.rb', line 45

def fetch
  headlines = LideoController.new.fetch(group(options))
  puts 'No news for you this time' if headlines.empty?

  export_html(headlines) && return if options[:to] && options[:to].downcase == 'html'

  puts "#{banner}#{format_headlines_output(headlines)}" unless headlines.empty? || !options[:to].nil?
end