Module: Kernel

Defined in:
lib/open-uri-and-write/kernel_extensions.rb

Overview

Kernel extensions Careful monkeypatching

Class Method Summary collapse

Class Method Details

.open(name, *rest, &block) ⇒ Object

:doc:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/open-uri-and-write/kernel_extensions.rb', line 7

def open(name, *rest, &block) # :doc:
  if name.respond_to?(:open)
    name.open(*rest, &block)
  elsif name.respond_to?(:to_s) and
        name[/^(https?):\/\//] and
        rest.size > 0 and
        rest.first.to_s[/^[rwa]/]
    webdav_agent = OpenUriAndWrite::Handle.new(name, rest)
    if(block)
      yield webdav_agent
    else
      return webdav_agent
    end
  else
    open_uri_and_write_original(name, *rest, &block)
  end
end