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

- (Object) ptr (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

+ (Object) included(by)



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

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

Instance Method Details

- (Object) ==(other) 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

- (Object) hash



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

def hash
  @ptr.hash
end

- (Object) inspect



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

- (Object) to_s



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

def to_s
  @ptr
end