Class: VivlioStarter::CLI::PdfCommands::PdfOpener

Inherits:
Object
  • Object
show all
Defined in:
lib/vivlio_starter/cli/pdf.rb

Overview

macOS の Preview.app で PDF を開く

Instance Method Summary collapse

Constructor Details

#initialize(options, path) ⇒ PdfOpener

Returns a new instance of PdfOpener.



483
484
485
486
# File 'lib/vivlio_starter/cli/pdf.rb', line 483

def initialize(options, path)
  @options = options || {}
  @explicit_path = path
end

Instance Method Details

#callObject



488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/vivlio_starter/cli/pdf.rb', line 488

def call
  apply_verbose
  pdf_path = resolve_pdf_path
  Common.log_action('PDFを開いています…')
  Common.log_info("ファイルパス: #{File.expand_path(pdf_path)}")

  unless macos?
    inform_unsupported_platform
    return
  end

  ensure_pdf_exists(pdf_path)
  close_existing_windows_if_needed
  open_pdf(pdf_path)
  position_window
  # どのファイルを開いたかを既定ログレベルでも報告する(省略時は自動選択のため)
  Common.log_result("#{File.basename(pdf_path)} を開きました", status: :success)
end