lib/rio/scheme/strio.rb in rio-0.3.7 vs lib/rio/scheme/strio.rb in rio-0.3.8

- old
+ new

@@ -1,8 +1,8 @@ #-- # =============================================================================== -# Copyright (c) 2005, Christopher Kleckner +# Copyright (c) 2005, 2006 Christopher Kleckner # All rights reserved # # This file is part of the Rio library for ruby. # # Rio is free software; you can redistribute it and/or modify @@ -20,11 +20,11 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # =============================================================================== #++ # # To create the documentation for Rio run the command -# rake rdoc +# ruby build_doc.rb # from the distribution directory. Then point your browser at the 'doc/rdoc' directory. # # Suggested Reading # * RIO::Doc::SYNOPSIS # * RIO::Doc::INTRO @@ -45,12 +45,14 @@ RESET_STATE = 'StrIO::Stream::Open' class RL < RL::IOIBase RIOSCHEME = 'strio' RIOPATH = RIO::RL::CHMAP.invert[RIOSCHEME].to_s.freeze + attr_accessor :str def initialize(str="") @str = str + super end def opaque() sprintf('0x%08x',@str.object_id) end # must be able to process both @@ -65,34 +67,22 @@ [str] end end def open(m,*args) - ::StringIO.new(@str,m.to_s,*args) + super(::StringIO.new(@str,m.to_s,*args)) end end module Stream - class Open < RIO::Stream::Open - def input() stream_state('StrIO::Stream::Input') end - def output() stream_state('StrIO::Stream::Output') end - def inout() stream_state('StrIO::Stream::InOut') end - end - module Ops def string() ioh.string end def string=(p1) ioh.string = p1 end end - - class Input < RIO::Stream::Input - include Ops + class Open < RIO::Stream::Open + def string=(p1) rl.str = p1 end + def string() rl.str end + def stream_state(*args) super.extend(Ops) end end - - class Output < RIO::Stream::Output - include Ops - end - - class InOut < RIO::Stream::InOut - include Ops - end end end end +__END__