Module: BitGirder::Io::Testing
- Defined in:
- lib/bitgirder/io/testing.rb
Class Method Summary collapse
Class Method Details
.new_string_io(str = "") ⇒ Object
15 16 17 18 19 |
# File 'lib/bitgirder/io/testing.rb', line 15 def new_string_io( str = "" ) RubyVersions.when_19x( StringIO.new( str ) ) do |io| io.set_encoding( "binary" ) end end |
.rand_buf(len) ⇒ Object
23 24 25 26 27 |
# File 'lib/bitgirder/io/testing.rb', line 23 def rand_buf( len ) len = len.bytes if len.is_a?( DataSize ) File.open( "/dev/random", "rb" ) { |io| Io.read_full( io, len ) } end |