Class: OGR::StyleTable

Inherits:
Object
  • Object
show all
Includes:
Extensions
Defined in:
lib/ogr/style_table.rb,
lib/ogr/extensions/style_table/extensions.rb

Defined Under Namespace

Modules: Extensions

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Extensions

#styles

Constructor Details

#initialize(c_pointer = nil) ⇒ StyleTable



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ogr/style_table.rb', line 19

def initialize(c_pointer = nil)
  @c_pointer = if c_pointer
                 c_pointer
               else
                 pointer = FFI::OGR::API.OGR_STBL_Create
                 pointer.autorelease = false
                 FFI::AutoPointer.new(pointer, StyleTable.method(:release))
               end

  raise "Unable to create StyleTable" if @c_pointer.null?
end

Instance Attribute Details

#c_pointerFFI::Pointer (readonly)



16
17
18
# File 'lib/ogr/style_table.rb', line 16

def c_pointer
  @c_pointer
end

Class Method Details

.release(pointer) ⇒ Object



9
10
11
12
13
# File 'lib/ogr/style_table.rb', line 9

def self.release(pointer)
  return unless pointer && !pointer.null?

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

Instance Method Details

#add_style(name, style) ⇒ Boolean



40
41
42
# File 'lib/ogr/style_table.rb', line 40

def add_style(name, style)
  FFI::OGR::API.OGR_STBL_AddStyle(@c_pointer, name, style)
end

#destroy!Object



31
32
33
34
35
# File 'lib/ogr/style_table.rb', line 31

def destroy!
  StyleTable.release(@c_pointer)

  @c_pointer = nil
end

#find(style_name) ⇒ String?



46
47
48
# File 'lib/ogr/style_table.rb', line 46

def find(style_name)
  FFI::OGR::API.OGR_STBL_Find(@c_pointer, style_name)
end

#last_style_nameString?



51
52
53
# File 'lib/ogr/style_table.rb', line 51

def last_style_name
  FFI::OGR::API.OGR_STBL_GetLastStyleName(@c_pointer)
end

#load!(file_name) ⇒ Boolean



62
63
64
# File 'lib/ogr/style_table.rb', line 62

def load!(file_name)
  FFI::OGR::API.OGR_STBL_LoadStyleTable(@c_pointer, file_name)
end

#next_styleString?



56
57
58
# File 'lib/ogr/style_table.rb', line 56

def next_style
  FFI::OGR::API.OGR_STBL_GetNextStyle(@c_pointer)
end

#reset_style_string_readingObject

Resets the #next_style to the 0th style.



67
68
69
# File 'lib/ogr/style_table.rb', line 67

def reset_style_string_reading
  FFI::OGR::API.OGR_STBL_ResetStyleStringReading(@c_pointer)
end

#save(file_name) ⇒ Boolean



73
74
75
# File 'lib/ogr/style_table.rb', line 73

def save(file_name)
  FFI::OGR::API.OGR_STBL_SaveStyleTable(@c_pointer, file_name)
end