Module: Skyscraper::Path

Extended by:
ActiveSupport::Autoload
Defined in:
lib/skyscraper/path.rb,
lib/skyscraper/path/base.rb,
lib/skyscraper/path/local.rb,
lib/skyscraper/path/remote.rb

Defined Under Namespace

Classes: Base, Local, Remote

Class Method Summary collapse

Class Method Details

.absolute?(path) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/skyscraper/path.rb', line 24

def absolute? path
  path.starts_with? "/"
end

.factory(path) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/skyscraper/path.rb', line 10

def factory path
  if Path.remote?(path)
    Path::Remote.new(path)
  else
    Path::Local.new(path)
  end
end

.remote?(path) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/skyscraper/path.rb', line 18

def remote? path
  path = "http://"+path unless path.match /^(http|https):\/\//
  uri  = URI.parse(path)
  uri.host ? true : false
end