Module: GLib::ListMethods
Overview
Common methods for List and SList.
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#element_type ⇒ Object
readonly
Returns the value of attribute element_type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each ⇒ Object
- #head ⇒ Object
- #initialize(type) ⇒ Object
- #reset_typespec(typespec) ⇒ Object
- #tail ⇒ Object
Instance Attribute Details
#element_type ⇒ Object (readonly)
Returns the value of attribute element_type.
9 10 11 |
# File 'lib/ffi-glib/list_methods.rb', line 9 def element_type @element_type end |
Class Method Details
.included(base) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/ffi-glib/list_methods.rb', line 11 def self.included(base) # Override default field accessors. replace_method base, :next, :tail replace_method base, :data, :head base.extend ContainerClassMethods base.extend ClassMethods end |
.replace_method(base, old, new) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ffi-glib/list_methods.rb', line 20 def self.replace_method(base, old, new) base.class_eval do remove_method old alias_method old, new end end |
Instance Method Details
#==(other) ⇒ Object
56 57 58 |
# File 'lib/ffi-glib/list_methods.rb', line 56 def ==(other) to_a == other.to_a end |
#each ⇒ Object
32 33 34 35 36 37 |
# File 'lib/ffi-glib/list_methods.rb', line 32 def each reset_iterator while (elem = next_element) yield elem end end |
#head ⇒ Object
45 46 47 48 49 |
# File 'lib/ffi-glib/list_methods.rb', line 45 def head return nil if struct.null? GirFFI::ArgHelper.cast_from_pointer(element_type, struct[:data]) end |
#initialize(type) ⇒ Object
27 28 29 30 |
# File 'lib/ffi-glib/list_methods.rb', line 27 def initialize(type) store_pointer(FFI::Pointer.new(0)) @element_type = type end |
#reset_typespec(typespec) ⇒ Object
51 52 53 54 |
# File 'lib/ffi-glib/list_methods.rb', line 51 def reset_typespec(typespec) @element_type = typespec self end |
#tail ⇒ Object
39 40 41 42 43 |
# File 'lib/ffi-glib/list_methods.rb', line 39 def tail return nil if struct.null? self.class.wrap(element_type, struct[:next]) end |