Class: MyManga::CLI::Commands::Update

Inherits:
MyManga::CLI::Command show all
Defined in:
lib/my_manga/update.rb

Overview

See desc

Instance Method Summary collapse

Methods inherited from MyManga::CLI::Command

#manga_names, #pad

Instance Method Details

#call(names: nil, **options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/my_manga/update.rb', line 11

def call(names: nil, **options)
  names = manga_names(names)

  puts 'Fetching Manga'
  puts '...'

  names.each do |name|
    manga = MyManga[name]
    old_total = manga.total_count
    MyManga.update(manga)
    new_total = MyManga[name].total_count
    updated = new_total - old_total

    next if updated.zero?

    puts "Updated \"#{name}\": #{updated} new Chapters."
  end
end