class OGR::FieldDefinition

Attributes

c_pointer[R]

@return [FFI::Pointer] C pointer to the C FieldDefn.

Public Class Methods

new(name_or_pointer, type) click to toggle source

@param name_or_pointer [String, FFI::Pointer] @param type [FFI::OGR::FieldType]

# File lib/ogr/field_definition.rb, line 19
def initialize(name_or_pointer, type)
  pointer = if name_or_pointer.is_a? String
              FFI::OGR::API.OGR_Fld_Create(name_or_pointer, type)
            else
              name_or_pointer
            end

  if !pointer.is_a?(FFI::Pointer) || pointer.null?
    raise OGR::InvalidFieldDefinition, "Unable to create #{self.class.name} from #{name_or_pointer}"
  end

  @c_pointer = FFI::AutoPointer.new(pointer, FieldDefinition.method(:release))
  @c_pointer.autorelease = false
end
release(pointer) click to toggle source

@param pointer [FFI::Pointer]

# File lib/ogr/field_definition.rb, line 8
def self.release(pointer)
  return unless pointer && !pointer.null?

  FFI::OGR::API.OGR_Fld_Destroy(pointer)
end

Public Instance Methods

destroy!() click to toggle source
# File lib/ogr/field_definition.rb, line 34
def destroy!
  FieldDefinition.release(@c_pointer)

  @c_pointer = nil
end
ignore=(new_value) click to toggle source

@param new_value [Boolean]

# File lib/ogr/field_definition.rb, line 117
def ignore=(new_value)
  FFI::OGR::API.OGR_Fld_SetIgnored(@c_pointer, new_value)
end
ignored?() click to toggle source

@return [Boolean]

# File lib/ogr/field_definition.rb, line 112
def ignored?
  FFI::OGR::API.OGR_Fld_IsIgnored(@c_pointer)
end
justification() click to toggle source

@return [FFI::OGR::Justification]

# File lib/ogr/field_definition.rb, line 72
def justification
  FFI::OGR::API.OGR_Fld_GetJustify(@c_pointer)
end
justification=(new_value) click to toggle source

@param new_value [FFI::OGR::Justification]

# File lib/ogr/field_definition.rb, line 77
def justification=(new_value)
  FFI::OGR::API.OGR_Fld_SetJustify(@c_pointer, new_value)
end
name() click to toggle source

@return [String]

# File lib/ogr/field_definition.rb, line 59
def name
  name, ptr = FFI::OGR::API.OGR_Fld_GetNameRef(@c_pointer)
  ptr.autorelease = false

  name
end
name=(new_value) click to toggle source

@param new_value [String]

# File lib/ogr/field_definition.rb, line 67
def name=(new_value)
  FFI::OGR::API.OGR_Fld_SetName(@c_pointer, new_value)
end
precision() click to toggle source

@return [Integer]

# File lib/ogr/field_definition.rb, line 82
def precision
  FFI::OGR::API.OGR_Fld_GetPrecision(@c_pointer)
end
precision=(new_value) click to toggle source

@param new_value [Integer]

# File lib/ogr/field_definition.rb, line 87
def precision=(new_value)
  FFI::OGR::API.OGR_Fld_SetPrecision(@c_pointer, new_value)
end
set(name, type, width, precision, justification) click to toggle source

Set all defining attributes in one call.

@param name [String] @param type [FFI::OGR::FieldType] @param width [Integer] @param precision [Integer] @param justification [FFI::OGR::Justification]

# File lib/ogr/field_definition.rb, line 47
def set(name, type, width, precision, justification)
  FFI::OGR::API.OGR_Fld_Set(
    @c_pointer,
    name,
    type,
    width,
    precision,
    justification
  )
end
type() click to toggle source

@return [FFI::OGR::FieldType]

# File lib/ogr/field_definition.rb, line 92
def type
  FFI::OGR::API.OGR_Fld_GetType(@c_pointer)
end
type=(new_value) click to toggle source

@param new_value [FFI::OGR::FieldType]

# File lib/ogr/field_definition.rb, line 97
def type=(new_value)
  FFI::OGR::API.OGR_Fld_SetType(@c_pointer, new_value)
end
width() click to toggle source

@return [Integer]

# File lib/ogr/field_definition.rb, line 102
def width
  FFI::OGR::API.OGR_Fld_GetWidth(@c_pointer)
end
width=(new_value) click to toggle source

@param new_value [Integer]

# File lib/ogr/field_definition.rb, line 107
def width=(new_value)
  FFI::OGR::API.OGR_Fld_SetWidth(@c_pointer, new_value)
end