Sha256: b0e5ba44981d9ffc0993ae94fe2f6a313ffa63109fe0af54abb790ab932b11a8

Contents?: true

Size: 578 Bytes

Versions: 2

Compression:

Stored size: 578 Bytes

Contents

# Buffer structure
#
class Tidybuf

  extend DL::Importable
  
  # Access TidyBuffer instance
  #
  attr_reader(:struct)

  # Mimic TidyBuffer
  #
  TidyBuffer = struct [
    "byte* bp",
    "uint size",
    "uint allocated",
    "uint next"
  ]

  def initialize()
    @struct = TidyBuffer.malloc
  end
    
  # Free current contents and zero out
  #
  def free()
    Tidylib.buf_free(@struct)
  end

  # Convert to array
  #
  def to_a
    to_s.split("\r\n")
  end

  # Convert to string
  #
  def to_s
    @struct.bp.to_s
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tidy-1.0.1 lib/tidy/tidybuf.rb
tidy-1.0.0 lib/tidy/tidybuf.rb