Class: RIO::RL::PathBase

Inherits:
URIBase show all
Defined in:
lib/rio/rl/path.rb

Direct Known Subclasses

Path::RL, Temp::Dir::RL, Temp::File::RL

Constant Summary collapse

RESET_STATE =
'Path::Reset'

Constants inherited from URIBase

URIBase::HOST, URIBase::SCHEME

Constants inherited from WithPath

WithPath::HOST, WithPath::SCHEME

Instance Attribute Summary

Attributes inherited from URIBase

#uri

Attributes inherited from Base

#fs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from URIBase

#_get_base_from_arg, #_get_opts_from_args, #absolute?, #base, #base=, #host, #host=, #init_from_args_, #initialize, #initialize_copy, #opaque, #openfs_, #path, #path=, #pathroot, #urlpath, #urlpath=, #urlroot

Methods inherited from WithPath

#_build, #_parts, #_uri, #abs, #base, #basename, #dirname, #filename, #fspath=, #fspath_no_slash, #host, #host=, #is_root?, #merge, #opaque, #openfs_, #path, #path=, #path_no_slash, #pathdepth, #pathroot, #route_from, #route_to, #split, #uri, #uri_from_string_, #urlpath, #urlpath=

Methods included from Error::NotImplemented

#nodef

Methods inherited from Base

#==, #===, #=~, #callstr, #close, #escape, #fs2url, #initialize, #initialize_copy, is_riorl?, #length, #openfs_, parse, #path, #rl, split_riorl, subscheme, #to_rl, #unescape, #url2fs

Constructor Details

This class inherits a constructor from RIO::RL::URIBase

Class Method Details

.splitrl(s) ⇒ Object



99
100
101
102
103
104
105
106
# File 'lib/rio/rl/path.rb', line 99

def self.splitrl(s)
  sch,opq,whole = split_riorl(s)
  #p sch,opq,whole
  case sch
  when 'file' then [whole]
  else [opq]
  end
end

Instance Method Details

#arg0_info_(arg0, *args) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rio/rl/path.rb', line 46

def arg0_info_(arg0,*args)
  #p "arg0_info_(#{arg0.inspect},#{args.inspect})"
  #p callstr('init_from_args_',arg0.inspect,args)
  vuri,vbase,vfs = nil,nil,nil
  case arg0
  when RIO::Rio, URIBase, ::URI
    return super
  when ::String 
    vuri = uri_from_string_(RL.fs2url(arg0)) || ::URI.parse(RL.fs2url(arg0))
  else
    raise(ArgumentError,"'#{arg0}'[#{arg0.class}] can not be used to create a Rio")
  end
  #puts "path.rb arg0_info_: vuri=#{vuri}"
  [vuri,vbase,vfs]
end

#build_arg0_(path_str) ⇒ Object



61
62
63
# File 'lib/rio/rl/path.rb', line 61

def build_arg0_(path_str)
  RL.url2fs(path_str)
end

#fspathObject



81
82
83
84
85
86
87
# File 'lib/rio/rl/path.rb', line 81

def fspath() 
  if use_host?
    '//' + uri.host + RL.url2fs(self.urlpath)
  else 
    RL.url2fs(self.urlpath)
  end
end

#join(*args) ⇒ Object



77
78
79
80
# File 'lib/rio/rl/path.rb', line 77

def join(*args)
  return self if args.empty?
  join_(args.map{ |arg| RL.fs2url(arg.to_s)})
end

#schemeObject



64
65
66
# File 'lib/rio/rl/path.rb', line 64

def scheme() 
  uri.scheme || 'path' 
end

#to_sObject

end



96
97
98
# File 'lib/rio/rl/path.rb', line 96

def to_s()
  self.fspath
end

#urlObject



67
68
69
70
71
# File 'lib/rio/rl/path.rb', line 67

def url
  str = uri.to_s
  str = scheme + ':' +str unless uri.scheme
  str
end

#use_host?Boolean

Returns:

  • (Boolean)


72
73
74
75
# File 'lib/rio/rl/path.rb', line 72

def use_host?
  hst = uri.host
  !(hst.nil? || hst.empty? || hst == 'localhost')
end