Module: Weechat::Pointer

Included in:
Bar, Bar::Item, Buffer, Hook, IRC::Channel, Plugin, Script, Window
Defined in:
lib/weechat/pointer.rb

Overview

mixin for objects with a underlying implementation as a weechat c pointer. Gives the class access to the from_ptr class method, which will create new instance of the class using a pointer. Also defines the equality methods to compare pointer values

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ptrObject (readonly) Also known as: pointer

Returns the value of attribute ptr



18
19
20
# File 'lib/weechat/pointer.rb', line 18

def ptr
  @ptr
end

Class Method Details

.included(by) ⇒ Object



14
15
16
# File 'lib/weechat/pointer.rb', line 14

def self.included(by)
  by.extend Weechat::Pointer::ClassMethods
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?, equal?



25
26
27
# File 'lib/weechat/pointer.rb', line 25

def ==(other)
  other.respond_to?(:ptr) and @ptr == other.ptr
end

#hashObject



31
32
33
# File 'lib/weechat/pointer.rb', line 31

def hash
  @ptr.hash
end

#inspectObject



35
36
37
# File 'lib/weechat/pointer.rb', line 35

def inspect
  sprintf "#<%s:0x%x @ptr=%p>", self.class, object_id << 1, @ptr
end

#to_sObject



21
22
23
# File 'lib/weechat/pointer.rb', line 21

def to_s
  @ptr
end