Class: Command::Browser
- Inherits:
-
CommandBase
- Object
- CommandBase
- Command::Browser
- Defined in:
- lib/command/browser.rb
Instance Method Summary collapse
- #execute(argv) ⇒ Object
-
#initialize ⇒ Browser
constructor
A new instance of Browser.
- #oneline_help ⇒ Object
Methods inherited from CommandBase
Constructor Details
#initialize ⇒ Browser
Returns a new instance of Browser.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/command/browser.rb', line 10 def initialize super("<target> [<target2> ...]") @opt.separator "\n \u30FB\u6307\u5B9A\u3057\u305F\u5C0F\u8AAC\u306E\u63B2\u8F09\u30DA\u30FC\u30B8\u3092\u30D6\u30E9\u30A6\u30B6\u3067\u958B\u304D\u307E\u3059\u3002\n\n Example:\nnarou browser n9669bk\nnarou browser musyoku\n\n Options:\n EOS\n\n @opt.on(\"-v\", \"--vote\", \"\u6307\u5B9A\u3057\u305F\u5C0F\u8AAC\u306E\u6295\u7968\u30FB\u611F\u60F3\u3092\u6295\u7A3F\u3059\u308B\u30DA\u30FC\u30B8\u3092\u8868\u793A\u3059\u308B\") {\n @options[\"vote\"] = true\n }\nend\n" |
Instance Method Details
#execute(argv) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/command/browser.rb', line 28 def execute(argv) super if argv.empty? puts @opt.help return end argv.each do |target| data = Downloader.get_data_by_target(target) unless data error "#{target} は存在しません" next end toc_url = data["toc_url"] if ["vote"] # TODO: 最新話の場所をAPIで取得する data_dir = Downloader.get_novel_data_dir_by_target(data["id"]) latest_index = YAML.load_file(File.join(data_dir, Downloader::TOC_FILE_NAME))["subtitles"].last["index"] open_url = "#{toc_url + latest_index}/#f_cr" else open_url = toc_url end Helper.open_browser(open_url) puts open_url end end |
#oneline_help ⇒ Object
54 55 56 |
# File 'lib/command/browser.rb', line 54 def oneline_help "小説の掲載ページをブラウザで開きます" end |