Class: MyManga::CLI::Commands::Mark
- Inherits:
-
MyManga::CLI::Command
- Object
- Hanami::CLI::Command
- MyManga::CLI::Command
- MyManga::CLI::Commands::Mark
- Defined in:
- lib/my_manga/mark.rb
Overview
See desc
Instance Method Summary collapse
Methods inherited from MyManga::CLI::Command
Instance Method Details
#call(flag:, names: nil, **options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/my_manga/mark.rb', line 22 def call(flag:, names: nil, **) names = manga_names(names) if [:list] numbers = [:list].to_s.split(',').map(&:strip) output ||= numbers.join(', ') elsif [:to] numbers = (.fetch(:from)...fetch(:to)).to_a output = [numbers.first, numbers.last].join('-') end output ||= '(all)' names.each do |name| manga = MyManga[name] chapters = numbers || manga.chapters_numbers count = chapters.length next unless count.positive? mark(manga, flag, chapters) print %(Chapters #{output} from "#{name}" ) puts %(Marked as #{flag.capitalize}) end end |