Class
A base class for objects representing a C structure
Class Methods
::
ext/fiddle/lib/fiddle/struct.rb
View on GitHub
# File tmp/rubies/ruby-3.0.5/ext/fiddle/lib/fiddle/struct.rb, line 12
def CStruct.entity_class
CStructEntity
end
accessor to Fiddle::CStructEntity
Instance Methods
ext/fiddle/lib/fiddle/struct.rb
View on GitHub
# File tmp/rubies/ruby-3.0.5/ext/fiddle/lib/fiddle/struct.rb, line 16
def each
return enum_for(__function__) unless block_given?
self.class.members.each do |name,|
yield(self[name])
end
end
No documentation available
ext/fiddle/lib/fiddle/struct.rb
View on GitHub
# File tmp/rubies/ruby-3.0.5/ext/fiddle/lib/fiddle/struct.rb, line 24
def each_pair
return enum_for(__function__) unless block_given?
self.class.members.each do |name,|
yield(name, self[name])
end
end
No documentation available
ext/fiddle/lib/fiddle/struct.rb
View on GitHub
# File tmp/rubies/ruby-3.0.5/ext/fiddle/lib/fiddle/struct.rb, line 40
def replace(another)
if another.nil?
self.class.members.each do |name,|
self[name] = nil
end
elsif another.respond_to?(:each_pair)
another.each_pair do |name, value|
self[name] = value
end
else
another.each do |name, value|
self[name] = value
end
end
self
end
No documentation available
#
ext/fiddle/lib/fiddle/struct.rb
View on GitHub
# File tmp/rubies/ruby-3.0.5/ext/fiddle/lib/fiddle/struct.rb, line 32
def to_h
hash = {}
each_pair do |name, value|
hash[name] = unstruct(value)
end
hash
end
No documentation available
ext/fiddle/lib/fiddle/struct.rb
View on GitHub
# File tmp/rubies/ruby-3.0.5/ext/fiddle/lib/fiddle/struct.rb, line 58
def unstruct(value)
case value
when CStruct
value.to_h
when Array
value.collect do |v|
unstruct(v)
end
else
value
end
end
No documentation available