Module: GLib::ListMethods
Overview
Common methods for List and SList.
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 |
# 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 end |
.replace_method(base, old, new) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ffi-glib/list_methods.rb', line 19 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
51 52 53 |
# File 'lib/ffi-glib/list_methods.rb', line 51 def ==(other) to_a == other.to_a end |
#each ⇒ Object
31 32 33 34 35 36 |
# File 'lib/ffi-glib/list_methods.rb', line 31 def each reset_iterator while (elem = next_element) yield elem end end |
#head ⇒ Object
42 43 44 |
# File 'lib/ffi-glib/list_methods.rb', line 42 def head GirFFI::ArgHelper.cast_from_pointer(element_type, struct[:data]) end |
#initialize(type) ⇒ Object
26 27 28 29 |
# File 'lib/ffi-glib/list_methods.rb', line 26 def initialize(type) store_pointer(FFI::Pointer.new(0)) @element_type = type end |
#reset_typespec(typespec) ⇒ Object
46 47 48 49 |
# File 'lib/ffi-glib/list_methods.rb', line 46 def reset_typespec(typespec) @element_type = typespec self end |
#tail ⇒ Object
38 39 40 |
# File 'lib/ffi-glib/list_methods.rb', line 38 def tail self.class.wrap(element_type, struct[:next]) end |