Class: StringIO
- Inherits:
-
Object
- Object
- StringIO
- Defined in:
- lib/stringio_additions.rb
Class Method Summary collapse
Instance Method Summary collapse
- #byte ⇒ Object
- #cstring ⇒ Object
- #float ⇒ Object
- #get ⇒ Object
- #long ⇒ Object
- #remaining ⇒ Object
- #short ⇒ Object
- #signed_long ⇒ Object
Class Method Details
.allocate(size) ⇒ Object
10 11 12 |
# File 'lib/stringio_additions.rb', line 10 def self.allocate(size) new "\0" * size end |
Instance Method Details
#byte ⇒ Object
14 15 16 |
# File 'lib/stringio_additions.rb', line 14 def byte read(1)[0].ord end |
#cstring ⇒ Object
42 43 44 |
# File 'lib/stringio_additions.rb', line 42 def cstring gets("\0")[0..-2] end |
#float ⇒ Object
18 19 20 |
# File 'lib/stringio_additions.rb', line 18 def float read(4).unpack('e')[0] end |
#get ⇒ Object
22 23 24 |
# File 'lib/stringio_additions.rb', line 22 def get read remaining end |
#long ⇒ Object
26 27 28 |
# File 'lib/stringio_additions.rb', line 26 def long read(4).unpack('V')[0] end |
#remaining ⇒ Object
30 31 32 |
# File 'lib/stringio_additions.rb', line 30 def remaining size - pos end |
#short ⇒ Object
34 35 36 |
# File 'lib/stringio_additions.rb', line 34 def short read(2).unpack('v')[0] end |
#signed_long ⇒ Object
38 39 40 |
# File 'lib/stringio_additions.rb', line 38 def signed_long read(4).unpack('l')[0] end |