Class: Ganapati::FileUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/ganapati/utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, default_scheme = 'yourmom', default_host = 'localhost', default_port = 8118) ⇒ FileUrl

Returns a new instance of FileUrl.



5
6
7
8
9
10
11
12
# File 'lib/ganapati/utils.rb', line 5

def initialize(url, default_scheme='yourmom', default_host='localhost', default_port=8118)
  @url = url
  if @url.start_with? 'file://' or (not @url.start_with? 'hdfs://' and default_scheme == :file)
    parse_file_scheme
  else
    parse_hdfs_scheme(default_host, default_port)
  end
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



3
4
5
# File 'lib/ganapati/utils.rb', line 3

def host
  @host
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/ganapati/utils.rb', line 3

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



3
4
5
# File 'lib/ganapati/utils.rb', line 3

def port
  @port
end

#schemeObject (readonly)

Returns the value of attribute scheme.



3
4
5
# File 'lib/ganapati/utils.rb', line 3

def scheme
  @scheme
end

Instance Method Details

#hdfs?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ganapati/utils.rb', line 18

def hdfs?
  @scheme == :hdfs
end

#local?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/ganapati/utils.rb', line 22

def local?
  @scheme == :file
end

#to_sObject



14
15
16
# File 'lib/ganapati/utils.rb', line 14

def to_s
  @url
end