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



37
38
39
40
41
42
43
44
45
46
47
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
# File 'lib/rio/rl/builder.rb', line 37

def self.build(*a)
  a.flatten!
  a.push('') if a.empty?
  case a[0]
  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 ::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|^/|
      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
    a0 = a.shift.clone
    cl = Factory.instance.riorl_class(a0.scheme)
    o = cl.new(a0,*a) unless cl.nil?
    return o
  when ::RIO::RRL::Base
    a0 = a.shift.uri
    cl = Factory.instance.riorl_class(a0.scheme)
    o = cl.new(a0,*a) unless cl.nil?
    return o
  when ::Alt::URI::Base
    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 ::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



34
35
36
# File 'lib/rio/rl/builder.rb', line 34

def self.build_path_rl(rl)
  return rl
end