Sha256: 1eccf2a994b06e223c90d180d5c8308e4c028b203bde39cb3b5ef40f03d00688

Contents?: true

Size: 1.17 KB

Versions: 9

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require 'json'

module GDAL
  module RasterAttributeTableMixins
    module Extensions
      # @param row [Fixnum]
      # @param field [Fixnum]
      # @param value [String, Float, Fixnum]
      def set_value(row, field, value)
        case value.class
        when String then set_value_as_string(row, field, value)
        when Float then set_value_as_double(row, field, value)
        when Integer then set_value_as_integer(row, field, value)
        else raise GDAL::UnknownRasterAttributeTableType, "Unknown value type for value '#{value}'"
        end
      end

      # Get +column_name+, +column_usage+, +column_type+ as a Hash.
      #
      # @param index [Fixnum]
      # @return [Hash]
      def column(index)
        {
          name: column_name(index),
          usage: column_usage(index),
          type: column_type(index)
        }
      end

      # @return [Array<Hash>]
      def columns
        each_column.to_a
      end

      # @return [Enumerator]
      # @yieldparam [Hash]
      def each_column
        return enum_for(:each_column) unless block_given?

        column_count.times { |i| yield column(i) }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta16 lib/gdal/raster_attribute_table_mixins/extensions.rb
ffi-gdal-1.0.0.beta15 lib/gdal/raster_attribute_table_mixins/extensions.rb
ffi-gdal-1.0.0.beta14 lib/gdal/raster_attribute_table_mixins/extensions.rb
ffi-gdal-1.0.0.beta13 lib/gdal/raster_attribute_table_mixins/extensions.rb
ffi-gdal-1.0.0.beta12 lib/gdal/raster_attribute_table_mixins/extensions.rb
ffi-gdal-1.0.0.beta11 lib/gdal/raster_attribute_table_mixins/extensions.rb
ffi-gdal-1.0.0.beta10 lib/gdal/raster_attribute_table_mixins/extensions.rb
ffi-gdal-1.0.0.beta9 lib/gdal/raster_attribute_table_mixins/extensions.rb
ffi-gdal-1.0.0.beta8 lib/gdal/raster_attribute_table_mixins/extensions.rb