Class: Tidybuf

Inherits:
Object
  • Object
show all
Extended by:
DL::Importable
Defined in:
lib/tidy/tidybuf.rb

Overview

Buffer structure

Constant Summary collapse

TidyBuffer =

Mimic TidyBuffer

struct [
  "byte* bp",
  "uint size",
  "uint allocated",
  "uint next"
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTidybuf

Returns a new instance of Tidybuf.



20
21
22
# File 'lib/tidy/tidybuf.rb', line 20

def initialize()
  @struct = TidyBuffer.malloc
end

Instance Attribute Details

#structObject (readonly)

Access TidyBuffer instance



9
10
11
# File 'lib/tidy/tidybuf.rb', line 9

def struct
  @struct
end

Instance Method Details

#freeObject

Free current contents and zero out



26
27
28
# File 'lib/tidy/tidybuf.rb', line 26

def free()
  Tidylib.buf_free(@struct)
end

#to_aObject

Convert to array



32
33
34
# File 'lib/tidy/tidybuf.rb', line 32

def to_a
  to_s.split("\r\n")
end

#to_sObject

Convert to string



38
39
40
# File 'lib/tidy/tidybuf.rb', line 38

def to_s
  @struct.bp.to_s
end