Class: OGR::FieldDefinition
- Inherits:
-
Object
- Object
- OGR::FieldDefinition
- Defined in:
- lib/ogr/field_definition.rb
Instance Attribute Summary collapse
-
#c_pointer ⇒ FFI::Pointer
readonly
C pointer to the C FieldDefn.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy! ⇒ Object
- #ignore=(new_value) ⇒ Object
- #ignored? ⇒ Boolean
-
#initialize(name_or_pointer, type) ⇒ FieldDefinition
constructor
A new instance of FieldDefinition.
- #justification ⇒ FFI::OGR::Justification
- #justification=(new_value) ⇒ Object
- #name ⇒ String
- #name=(new_value) ⇒ Object
- #precision ⇒ Integer
- #precision=(new_value) ⇒ Object
-
#set(name, type, width, precision, justification) ⇒ Object
Set all defining attributes in one call.
- #type ⇒ FFI::OGR::FieldType
- #type=(new_value) ⇒ Object
- #width ⇒ Integer
- #width=(new_value) ⇒ Object
Constructor Details
#initialize(name_or_pointer, type) ⇒ FieldDefinition
Returns a new instance of FieldDefinition.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |
Instance Attribute Details
#c_pointer ⇒ FFI::Pointer (readonly)
Returns C pointer to the C FieldDefn.
15 16 17 |
# File 'lib/ogr/field_definition.rb', line 15 def c_pointer @c_pointer end |
Class Method Details
Instance Method Details
#destroy! ⇒ Object
34 35 36 37 38 |
# File 'lib/ogr/field_definition.rb', line 34 def destroy! FieldDefinition.release(@c_pointer) @c_pointer = nil end |
#ignore=(new_value) ⇒ Object
117 118 119 |
# File 'lib/ogr/field_definition.rb', line 117 def ignore=(new_value) FFI::OGR::API.OGR_Fld_SetIgnored(@c_pointer, new_value) end |
#ignored? ⇒ Boolean
112 113 114 |
# File 'lib/ogr/field_definition.rb', line 112 def ignored? FFI::OGR::API.OGR_Fld_IsIgnored(@c_pointer) end |
#justification ⇒ FFI::OGR::Justification
72 73 74 |
# File 'lib/ogr/field_definition.rb', line 72 def justification FFI::OGR::API.OGR_Fld_GetJustify(@c_pointer) end |
#justification=(new_value) ⇒ Object
77 78 79 |
# File 'lib/ogr/field_definition.rb', line 77 def justification=(new_value) FFI::OGR::API.OGR_Fld_SetJustify(@c_pointer, new_value) end |
#name ⇒ String
59 60 61 62 63 64 |
# 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) ⇒ Object
67 68 69 |
# File 'lib/ogr/field_definition.rb', line 67 def name=(new_value) FFI::OGR::API.OGR_Fld_SetName(@c_pointer, new_value) end |
#precision ⇒ Integer
82 83 84 |
# File 'lib/ogr/field_definition.rb', line 82 def precision FFI::OGR::API.OGR_Fld_GetPrecision(@c_pointer) end |
#precision=(new_value) ⇒ Object
87 88 89 |
# 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) ⇒ Object
Set all defining attributes in one call.
47 48 49 50 51 52 53 54 55 56 |
# 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 ⇒ FFI::OGR::FieldType
92 93 94 |
# File 'lib/ogr/field_definition.rb', line 92 def type FFI::OGR::API.OGR_Fld_GetType(@c_pointer) end |
#type=(new_value) ⇒ Object
97 98 99 |
# File 'lib/ogr/field_definition.rb', line 97 def type=(new_value) FFI::OGR::API.OGR_Fld_SetType(@c_pointer, new_value) end |