Class: Vivlio::Starter::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.



389
390
391
392
393
394
# File 'lib/vivlio/starter/cli/pdf.rb', line 389

def initialize(options, path)
  @options = options || {}
  @explicit_path = path
  @pdf_config = Common::CONFIG['pdf'] || {}
  @pdf_preview_config = Common::CONFIG.dig('output', 'pdf_preview') || {}
end

Instance Method Details

#callObject



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/vivlio/starter/cli/pdf.rb', line 396

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_success('PDFを開きました')
end