Method: Command::Browser#execute

Defined in:
lib/command/browser.rb

#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"]
      # 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}/#my_novelpoint"
    else
      open_url = toc_url
    end
    Helper.open_browser(open_url)
    puts open_url
  end
end