Class: Omnizip::IO::Source::StringSource

Inherits:
Source
  • Object
show all
Defined in:
lib/omnizip/io/source.rb

Overview

String input adapter. Treats the value as a file path if it exists on disk and contains no NUL bytes, otherwise as raw bytes.

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ StringSource

Returns a new instance of StringSource.



63
64
65
66
# File 'lib/omnizip/io/source.rb', line 63

def initialize(value)
  super(nil)
  @value = value
end

Instance Method Details

#closeObject



76
# File 'lib/omnizip/io/source.rb', line 76

def close; end

#read(_length = nil, _outbuf = nil) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/omnizip/io/source.rb', line 68

def read(_length = nil, _outbuf = nil)
  if file_path?
    File.binread(@value)
  else
    @value.b
  end
end