Class: Command::Download
- Inherits:
-
CommandBase
- Object
- CommandBase
- Command::Download
- Defined in:
- lib/command/download.rb
Instance Method Summary collapse
- #execute(argv) ⇒ Object
-
#initialize ⇒ Download
constructor
A new instance of Download.
- #oneline_help ⇒ Object
Methods inherited from CommandBase
Constructor Details
#initialize ⇒ Download
Returns a new instance of Download.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/command/download.rb', line 11 def initialize super("<target> [<target2> ...] [options]") @opt.separator "\n \u30FB\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u3057\u305F\u3044\u5C0F\u8AAC\u306EN\u30B3\u30FC\u30C9\u3082\u3057\u304F\u306FURL\u3092\u6307\u5B9A\u3057\u3066\u4E0B\u3055\u3044\u3002\n \u30FB\u4E00\u5EA6\u306B\u8907\u6570\u306E\u5C0F\u8AAC\u3092\u6307\u5B9A\u3059\u308B\u5834\u5408\u306F\u7A7A\u767D\u3067\u533A\u5207\u3063\u3066\u4E0B\u3055\u3044\u3002\n \u30FB\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u7D42\u4E86\u5F8C\u306B\u5909\u63DB\u51E6\u7406\u3092\u884C\u3044\u307E\u3059\u3002\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u306E\u307F\u3059\u308B\u5834\u5408\u306F-n\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u6307\u5B9A\u3057\u3066\u4E0B\u3055\u3044\u3002\n \u30FB\u3059\u3067\u306B\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u6E08\u307F\u306E\u5C0F\u8AAC\u306E\u5834\u5408\u306F\u4F55\u3082\u3057\u307E\u305B\u3093\u3002\n\n Example:\nnarou download n9669bk\nnarou download http://ncode.syosetu.com/n9669bk/\nnarou download n9669bk http://ncode.syosetu.com/n4259s/\nnarou download 0 1 -f\nnarou download n9669bk -n\n\n Options:\n EOS\n @opt.on(\"-f\", \"--force\", \"\u5168\u8A71\u3092\u5F37\u5236\u518D\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u3059\u308B\") {\n @options[\"force\"] = true\n }\n @opt.on(\"-n\", \"--no-convert\", \"\u5909\u63DB\u3092\u305B\u305A\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u306E\u307F\u5B9F\u884C\u3059\u308B\") {\n @options[\"no-convert\"] = true\n }\nend\n" |
Instance Method Details
#execute(argv) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/command/download.rb', line 37 def execute(argv) super if argv.empty? puts @opt.help return end argv.each.with_index(1) do |target, i| download_target ||= target Helper.print_horizontal_rule if i > 1 data = Downloader.get_data_by_target(download_target) if Narou.novel_frozen?(download_target) puts "#{data["title"]} は凍結中です\nダウンロードを中止しました" next end if !["force"] && data if Downloader.get_novel_data_dir_by_target(download_target) puts "#{download_target} はダウンロード済みです。" puts "ID: #{data["id"]}" puts "title: #{data["title"]}" else if Helper.confirm("再ダウンロードしますか") download_target = data["toc_url"] redo end end next end unless Downloader.start(download_target, ["force"], true) next end unless ["no-convert"] Convert.execute_and_rescue_exit([download_target]) end end end |
#oneline_help ⇒ Object
73 74 75 |
# File 'lib/command/download.rb', line 73 def oneline_help "指定した小説をダウンロードします" end |