Class: Tidybuf
- Inherits:
-
Object
- Object
- Tidybuf
- Extended by:
- DL::Importable
- Defined in:
- lib/tidy/tidybuf.rb
Overview
Buffer structure.
Constant Summary collapse
- TidyBuffer =
Mimic TidyBuffer.
struct [ "TidyAllocator* allocator", "byte* bp", "uint size", "uint allocated", "uint next" ]
Instance Attribute Summary collapse
-
#struct ⇒ Object
readonly
Access TidyBuffer instance.
Instance Method Summary collapse
-
#free ⇒ Object
Free current contents and zero out.
-
#initialize ⇒ Tidybuf
constructor
A new instance of Tidybuf.
-
#to_a ⇒ Object
Convert to array.
-
#to_s ⇒ Object
Convert to string.
Constructor Details
#initialize ⇒ Tidybuf
Returns a new instance of Tidybuf.
21 22 23 24 |
# File 'lib/tidy/tidybuf.rb', line 21 def initialize @struct = TidyBuffer.malloc Tidylib.buf_init(@struct) end |
Instance Attribute Details
#struct ⇒ Object (readonly)
Access TidyBuffer instance.
9 10 11 |
# File 'lib/tidy/tidybuf.rb', line 9 def struct @struct end |
Instance Method Details
#free ⇒ Object
Free current contents and zero out.
28 29 30 |
# File 'lib/tidy/tidybuf.rb', line 28 def free Tidylib.buf_free(@struct) end |
#to_a ⇒ Object
Convert to array.
34 35 36 |
# File 'lib/tidy/tidybuf.rb', line 34 def to_a to_s.split("\r\n") end |
#to_s ⇒ Object
Convert to string.
40 41 42 |
# File 'lib/tidy/tidybuf.rb', line 40 def to_s @struct.bp ? @struct.bp.to_s(@struct.size) : '' end |