Class: Command::Browser
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from CommandBase
#execute!, execute!, #force_change_settings_function, help, #hook_call, #load_local_settings, #tagname_to_ids
Constructor Details
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/command/browser.rb', line 14
def initialize
super("<target> [<target2> ...] [options]")
@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 Examples:\nnarou browser n9669bk\nnarou browser musyoku -v\nnarou b 0\n\n Options:\n EOS\n\n @opt.on(\"-v\", \"--vote\", \"\u5C0F\u8AAC\u306E\u6295\u7968\u30FB\u611F\u60F3\u3092\u6295\u7A3F\u3059\u308B\u30DA\u30FC\u30B8\u3092\u8868\u793A\u3059\u308B(\u306A\u308D\u3046\u306E\u307F)\") {\n @options[\"vote\"] = true\n }\nend\n"
|
Class Method Details
.oneline_help ⇒ Object
10
11
12
|
# File 'lib/command/browser.rb', line 10
def self.oneline_help
"小説の掲載ページをブラウザで開きます"
end
|
Instance Method Details
#execute(argv) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/command/browser.rb', line 33
def execute(argv)
super
if argv.empty?
puts @opt.help
return
end
tagname_to_ids(argv)
argv.each do |target|
data = Downloader.get_data_by_target(target)
unless data
error "#{target} は存在しません"
next
end
toc_url = data["toc_url"]
if @options["vote"]
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}/#my_novelpoint"
else
open_url = toc_url
end
Helper.open_browser(open_url)
puts open_url
end
end
|