Module: Gio::File

Extended by:
GLib::Deprecatable
Defined in:
lib/gio2/file.rb,
lib/gio2/deprecated.rb
more...

Class Method Summary collapse

Class Method Details

.open(options = {}) ⇒ Object

[View source]

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/gio2/file.rb', line 20

def open(options={})
  arg = options[:arg]
  cwd = options[:cwd]
  path = options[:path]
  uri = options[:uri]

  if arg
    if cwd
      file = new_for_commandline_arg_and_cmd(arg, cwd)
    else
      file = new_for_commandline_arg(arg)
    end
  elsif path
    file = new_for_path(path)
  elsif uri
    file = new_for_uri(uri)
  else
    message = "must specify :arg, :path or :uri: #{options.inspect}"
    raise ArgumentError, message
  end

  if block_given?
    yield(file)
  else
    file
  end
end