Method: CommandKit::OpenApp#open_app_for

Defined in:
lib/command_kit/open_app.rb

#open_app_for(file_or_uri) ⇒ Boolean?

Opens a file or URI using the system's preferred application for that file type or URI scheme.

Examples:

Open a file:

open_app_for "movie.avi"

Open a URI:

open_app_for "https://github.com/postmodern/command_kit.rb"

Parameters:

  • file_or_uri (String, URI)

    The file path or URI to open.

Returns:

  • (Boolean, nil)

    Specifies whether the file or URI was successfully opened or not. If the open command could not be determined, nil is returned.

Since:

  • 0.2.0



65
66
67
68
69
# File 'lib/command_kit/open_app.rb', line 65

def open_app_for(file_or_uri)
  if @open_command
    system(@open_command,file_or_uri.to_s)
  end
end