Sha256: 5a3223aa7bda14e2716f45f45edb73aaa9e85e0dd2c15a73d554421358214aa0
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require 'ffi' module GDAL # A wrapper for the way GDAL does key/value pair options for methods. class Options < Hash # Shortcut for if you just want to build the options and get the pointer to # them. # # @param hash [Hash] # @return [FFI::MemoryPointer, nil] def self.pointer(hash) hash.empty? ? nil : new(hash).c_pointer end def initialize(hash={}) super() capitalize_keys!(hash) end # @return [FFI::MemoryPointer] The double-char pointer that contains the # options for GDAL to use. def c_pointer options_ptr = FFI::MemoryPointer.new(:pointer, self.size) self.each do |key, value| options_ptr = FFI::GDAL.CSLSetNameValue(options_ptr, key, value) end options_ptr end # def to_s # options_ptr = to_gdal # options_array = options_ptr.read_array_of_pointer(self.size) # # 0.upto(self.size).map do |i| # options_array[i].first.read_string # end # end private def capitalize_keys!(hash) hash.each_with_object(self) do |(key, value), obj| obj[key.to_s.upcase] = value end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ffi-gdal-1.0.0.beta3 | lib/gdal/options.rb |
ffi-gdal-1.0.0.beta1 | lib/gdal/options.rb |