Class: SeriesTimer::Application
- Inherits:
-
Object
- Object
- SeriesTimer::Application
- Defined in:
- lib/series_timer.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Application
constructor
A new instance of Application.
- #parse_options(argv) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Application
Returns a new instance of Application.
12 13 14 |
# File 'lib/series_timer.rb', line 12 def initialize(argv) @params, @series = (argv) end |
Instance Method Details
#parse_options(argv) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/series_timer.rb', line 16 def (argv) params = {} parser = OptionParser.new parser.on("-f") { params[:options] = :force } parser.on("-n") { params[:episodes] = :next } parser.on("-l") { params[:episodes] = :last } parser.on("-a") { params[:episodes] = :all } series = parser.parse(argv) raise ArgumentError if series.empty? [params, series] end |
#run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/series_timer.rb', line 28 def run @series.each do |serie| case @params[:episodes] when :last puts SeriesManager.last_episode(serie, @params[:options]) when :all puts SeriesManager.all_episodes(serie, @params[:options]) else puts SeriesManager.next_episode(serie, @params[:options]) end end end |