leon 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/string-buffer.rb +9 -6
- metadata +1 -1
data/lib/string-buffer.rb
CHANGED
@@ -395,15 +395,18 @@ module LEON
|
|
395
395
|
isRead = false
|
396
396
|
end
|
397
397
|
i = args[0]
|
398
|
-
if
|
398
|
+
if i < 0 and (@buffer.length == 0)
|
399
399
|
return 0
|
400
400
|
end
|
401
|
-
if
|
402
|
-
|
403
|
-
|
404
|
-
|
401
|
+
if i < 0
|
402
|
+
offset = @buffer.length + (isRead ? 0 : 1) + i
|
403
|
+
else
|
404
|
+
offset = i
|
405
|
+
end
|
406
|
+
if offset < 0 or offset > @buffer.length - (isRead ? 1 : 0)
|
407
|
+
raise "Tried to #{isRead ? "read" : "write"} at index #{i} but it is out of range."
|
405
408
|
end
|
406
|
-
return
|
409
|
+
return offset;
|
407
410
|
end
|
408
411
|
end
|
409
412
|
end
|