Class: YARP::LibRubyParser::YPString

Inherits:
Object
  • Object
show all
Defined in:
lib/yarp/ffi.rb

Overview

This object represents a yp_string_t. We only use it as an opaque pointer, so it doesn’t have to be an FFI::Struct.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pointer) ⇒ YPString

Returns a new instance of YPString.



121
122
123
# File 'lib/yarp/ffi.rb', line 121

def initialize(pointer)
  @pointer = pointer
end

Instance Attribute Details

#pointerObject (readonly)

Returns the value of attribute pointer.



119
120
121
# File 'lib/yarp/ffi.rb', line 119

def pointer
  @pointer
end

Instance Method Details

#lengthObject



129
130
131
# File 'lib/yarp/ffi.rb', line 129

def length
  LibRubyParser.yp_string_length(pointer)
end

#readObject



133
134
135
# File 'lib/yarp/ffi.rb', line 133

def read
  source.read_string(length)
end

#sourceObject



125
126
127
# File 'lib/yarp/ffi.rb', line 125

def source
  LibRubyParser.yp_string_source(pointer)
end