Class: RIO::StrIO::RRL

Inherits:
RRL::IOIBase show all
Defined in:
lib/rio/scheme/strio.rb

Constant Summary collapse

RIOSCHEME =
'strio'
RIOPATH =
RIO::RRL::CHMAP.invert[RIOSCHEME].to_s.freeze

Constants inherited from RRL::IOIBase

RRL::IOIBase::RESET_STATE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RRL::IOIBase

#fspath, #opaque, #openfs_, #path, #scheme, #to_s

Methods inherited from Base

#to_a

Constructor Details

#initialize(u, str = "") ⇒ RRL

Returns a new instance of RRL.



39
40
41
42
43
44
# File 'lib/rio/scheme/strio.rb', line 39

def initialize(u,str="")
  alturi = ::Alt::URI.parse(u.to_s)
  super(alturi)
  self.query ||= str
  @sio = self.query
end

Instance Attribute Details

#strObject

Returns the value of attribute str.



38
39
40
# File 'lib/rio/scheme/strio.rb', line 38

def str
  @str
end

Class Method Details

.parse(*a) ⇒ Object



45
46
47
48
# File 'lib/rio/scheme/strio.rb', line 45

def self.parse(*a)
  u = a.shift.sub(/^rio:/,'')
  new(u,*a)
end

Instance Method Details

#open(m, *args) ⇒ Object



63
64
65
66
67
68
# File 'lib/rio/scheme/strio.rb', line 63

def open(m,*args)
  strio = self.stringio
  str = strio.string
  nstrio = self.stringio.reopen(str,m.to_s)
  super(nstrio)
end

#queryObject Also known as: stringio



58
59
60
# File 'lib/rio/scheme/strio.rb', line 58

def query
  uri.query.nil? ? nil :  ObjectSpace._id2ref(uri.query.hex)
end

#query=(arg) ⇒ Object Also known as: stringio=



49
50
51
52
53
54
55
56
57
# File 'lib/rio/scheme/strio.rb', line 49

def query=(arg)
  uri.query = if arg.nil?
                nil 
              else
                @sio = (::StringIO === arg ? arg : ::StringIO.new(arg))
                sprintf('0x%08x',@sio.object_id)
              end
  arg
end