Class: Tidybuf

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

Overview

Buffer structure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTidybuf

Returns a new instance of Tidybuf.



11
12
13
# File 'lib/tidy/tidybuf.rb', line 11

def initialize
  @struct = self.class.struct(construct_tidy_buffer).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.



17
18
19
# File 'lib/tidy/tidybuf.rb', line 17

def free
  Tidylib.buf_free(@struct)
end

#to_aObject

Convert to array.



23
24
25
# File 'lib/tidy/tidybuf.rb', line 23

def to_a
  to_s.split($/)
end

#to_sObject

Convert to string.



29
30
31
# File 'lib/tidy/tidybuf.rb', line 29

def to_s
  @struct.bp ? @struct.bp.to_s(@struct.size) : ''
end