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.
7 8 9 |
# File 'lib/ffi-glib/list_methods.rb', line 7 def element_type @element_type end |
Class Method Details
.included(base) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/ffi-glib/list_methods.rb', line 9 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
17 18 19 20 21 22 |
# File 'lib/ffi-glib/list_methods.rb', line 17 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
49 50 51 |
# File 'lib/ffi-glib/list_methods.rb', line 49 def ==(other) to_a == other.to_a end |
#each ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ffi-glib/list_methods.rb', line 29 def each reset_iterator while (elem = next_element) yield elem end end |
#head ⇒ Object
40 41 42 |
# File 'lib/ffi-glib/list_methods.rb', line 40 def head GirFFI::ArgHelper.cast_from_pointer(element_type, @struct[:data]) end |
#initialize(type) ⇒ Object
24 25 26 27 |
# File 'lib/ffi-glib/list_methods.rb', line 24 def initialize(type) store_pointer(FFI::Pointer.new(0)) @element_type = type end |
#reset_typespec(typespec) ⇒ Object
44 45 46 47 |
# File 'lib/ffi-glib/list_methods.rb', line 44 def reset_typespec(typespec) @element_type = typespec self end |
#tail ⇒ Object
36 37 38 |
# File 'lib/ffi-glib/list_methods.rb', line 36 def tail self.class.wrap(element_type, @struct[:next]) end |