Class: RIO::RL::Builder

Inherits:
Object show all
Defined in:
lib/rio/rl/builder.rb

Class Method Summary collapse

Class Method Details

.build(*a) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/rio/rl/builder.rb', line 48

def self.build(*a)
  #puts "build: #{a.inspect}" 
  a.flatten!
  a.push('') if a.empty?
  case a[0]
  when ::String
    case a[0]
    when /^[a-zA-Z]:/
      a[0] = 'rio:file:///'+a[0]
    when /^[a-z][a-z]+:/
      a[0] = 'rio:'+a[0] unless a[0] =~ /^rio:/
    when %r|^//|
      a[0] = 'rio:file:'+a[0]
    when %r|^/|
      a[0] = 'file://'+a[0]
      return Factory.instance.riorl_class('file').new(*a)
    else
      return Factory.instance.riorl_class('path').new(*a)
    end
  when RIO::Rio
    a[0] = a[0].rl
    return build(*a)
  when RL::Base
    #p "HERE a=#{a.inspect}"
    a0 = a.shift.clone
    cl = Factory.instance.riorl_class(a0.scheme)
    o = cl.new(a0,*a) unless cl.nil?
    return o
    #          return (a.empty? ? a0 : a0.join(*a))
  when ::URI
    a0 = a.shift
    cl = Factory.instance.riorl_class(a0.scheme)
    o = cl.new(a0,*a) unless cl.nil?
    return o
  when ::Symbol
    case a[0]
    when :zpath
      a0 = a.shift
      cl = Factory.instance.riorl_class(a0.to_s)
      o = cl.new(*a) unless cl.nil?
      return o
    else
      a[0] = 'rio:' + a[0].to_s + ':'
    end
  when ::NilClass
    a[0] = 'rio:null:'
  when ?? , ?= , ?_ , ?", ?[, ?#, ?`, ?|, ?z
    a[0] = 'rio:'+CHMAP[a[0]]+':'
  when ?-
    a[0] = ( a.size == 1 ? 'rio:'+CHMAP[a[0]]+':' : 'rio:cmdio:' )
  when ?$
    a[0] = 'rio:strio:'
  when ::IO
    a.unshift('rio:sysio:')
  when ::StringIO
    a.unshift('rio:strio:')
  else
    a[0] = a[0].to_s
    return build(*a)
  end
  a0 = a.shift
  sch = Base.subscheme(a0)
  cl = Factory.instance.riorl_class(sch)
  cl.parse(a0,*a)  unless cl.nil?

end

.build_path_rl(rl) ⇒ Object



45
46
47
# File 'lib/rio/rl/builder.rb', line 45

def self.build_path_rl(rl)
  return rl
end