Class: Skyscraper::Path::Remote

Inherits:
Base
  • Object
show all
Defined in:
lib/skyscraper/path/remote.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#local?, #path_for, #remote?

Constructor Details

#initialize(path) ⇒ Remote

Returns a new instance of Remote.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/skyscraper/path/remote.rb', line 6

def initialize path
  uri = URI.parse(path)

  if uri.scheme.present?
    @domain = uri.scheme + "://" + uri.host
  else
    @domain = uri.host
  end

  @path      = uri.path
  @query     = "?" + uri.query if uri.query
  @full_path = "#{@domain}#{@path}#{@query}"
  @base      = "#{@domain}/"
  @uri       = uri
  @file_name = get_file_name(@path)
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



4
5
6
# File 'lib/skyscraper/path/remote.rb', line 4

def base
  @base
end

#domainObject

Returns the value of attribute domain.



4
5
6
# File 'lib/skyscraper/path/remote.rb', line 4

def domain
  @domain
end

#file_nameObject

Returns the value of attribute file_name.



4
5
6
# File 'lib/skyscraper/path/remote.rb', line 4

def file_name
  @file_name
end

#full_pathObject

Returns the value of attribute full_path.



4
5
6
# File 'lib/skyscraper/path/remote.rb', line 4

def full_path
  @full_path
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/skyscraper/path/remote.rb', line 4

def path
  @path
end

#queryObject

Returns the value of attribute query.



4
5
6
# File 'lib/skyscraper/path/remote.rb', line 4

def query
  @query
end

#uriObject

Returns the value of attribute uri.



4
5
6
# File 'lib/skyscraper/path/remote.rb', line 4

def uri
  @uri
end

Instance Method Details

#full_path_for(href) ⇒ Object



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

def full_path_for href
  @uri.merge(URI.parse(href)).to_s
end

#to_sObject



27
28
29
# File 'lib/skyscraper/path/remote.rb', line 27

def to_s
  self.full_path
end