Class: Secure::Data
- Inherits:
-
Object
- Object
- Secure::Data
- Defined in:
- lib/appswarm/secure_marshal.rb
Overview
This is an interal class to keep track of data parsing, so that not too much data is copied from here to there.
Instance Method Summary collapse
-
#initialize(data) ⇒ Data
constructor
A new instance of Data.
- #read(len) ⇒ Object
- #str ⇒ Object
- #til(str) ⇒ Object
Constructor Details
#initialize(data) ⇒ Data
Returns a new instance of Data.
15 16 17 18 |
# File 'lib/appswarm/secure_marshal.rb', line 15 def initialize(data) @data=data @pos=0 end |
Instance Method Details
#read(len) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/appswarm/secure_marshal.rb', line 19 def read(len) raise Secure::Marshal::OutOfData.new(@data) if @data.length<@pos+len cur=@data[@pos...(@pos+len)] @pos+=cur.length cur end |
#str ⇒ Object
35 36 37 |
# File 'lib/appswarm/secure_marshal.rb', line 35 def str @data[@pos..-1] end |