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.



565
566
567
568
# File 'lib/vivlio_starter/cli/pdf.rb', line 565

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

Instance Method Details

#callObject



570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
# File 'lib/vivlio_starter/cli/pdf.rb', line 570

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