Class: Nxxd::WriteChunksString
- Inherits:
-
Object
- Object
- Nxxd::WriteChunksString
- Defined in:
- lib/nxxd.rb
Instance Method Summary collapse
-
#initialize(str) ⇒ WriteChunksString
constructor
A new instance of WriteChunksString.
- #seek(pos) ⇒ Object
- #set_encoding(enc) ⇒ Object
- #tell ⇒ Object
- #write(b) ⇒ Object
Constructor Details
#initialize(str) ⇒ WriteChunksString
Returns a new instance of WriteChunksString.
179 180 181 |
# File 'lib/nxxd.rb', line 179 def initialize str @str = str end |
Instance Method Details
#seek(pos) ⇒ Object
186 187 188 189 190 191 192 193 |
# File 'lib/nxxd.rb', line 186 def seek pos s = pos - @str.length if s >= 0 then s.times { @str << "\0".b } else @pos = pos end end |
#set_encoding(enc) ⇒ Object
182 183 184 |
# File 'lib/nxxd.rb', line 182 def set_encoding enc @str.force_encoding enc end |
#tell ⇒ Object
185 |
# File 'lib/nxxd.rb', line 185 def tell ; @pos || @str.length ; end |
#write(b) ⇒ Object
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/nxxd.rb', line 194 def write b if @pos then l = b.length @str[ @pos, l] = b @pos += l @pos = nil if @pos >= @str.length else @str << b end end |