Class: OGR::StyleTool
- Inherits:
-
Object
- Object
- OGR::StyleTool
- Defined in:
- lib/ogr/style_tool.rb
Instance Attribute Summary collapse
-
#c_pointer ⇒ FFI::Pointer
readonly
C pointer to the C style tool.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(style_tool_class) ⇒ StyleTool
constructor
A new instance of StyleTool.
- #param_as_double(param_number) ⇒ Float? (also: #param_as_float)
- #param_as_number(param_number) ⇒ Integer? (also: #param_as_integer)
- #param_as_string(param_number) ⇒ String?
-
#rgb_from_string(color_string) ⇒ Hash{red => Integer, green => Integer, blue => Integer, alpha => Integer}
Returns the R, G, B, A components of a #RRGGBB formatted string.
- #set_param_as_double(param_number, value) ⇒ Object (also: #set_param_as_float)
- #set_param_as_number(param_number, value) ⇒ Object (also: #set_param_as_integer)
- #set_param_as_string(param_number, value) ⇒ Object
- #set_unit(new_unit, ground_to_paper_scale) ⇒ Object
- #style_string ⇒ String?
- #type ⇒ FFI::OGR::Core::STClassId
- #unit ⇒ FFI::OGR::Core::STUnitId
Constructor Details
#initialize(style_tool_class) ⇒ StyleTool
Returns a new instance of StyleTool.
19 20 21 22 23 24 25 26 27 |
# File 'lib/ogr/style_tool.rb', line 19 def initialize(style_tool_class) pointer = FFI::OGR::API.OGR_ST_Create(style_tool_class) if !pointer || pointer.null? raise OGR::CreateFailure, "Unable to create StyleTool using class #{style_tool_class}" end @c_pointer = FFI::AutoPointer.new(pointer, StyleTool.method(:release)) end |
Instance Attribute Details
#c_pointer ⇒ FFI::Pointer (readonly)
Returns C pointer to the C style tool.
15 16 17 |
# File 'lib/ogr/style_tool.rb', line 15 def c_pointer @c_pointer end |
Class Method Details
Instance Method Details
#param_as_double(param_number) ⇒ Float? Also known as: param_as_float
55 56 57 58 59 60 |
# File 'lib/ogr/style_tool.rb', line 55 def param_as_double(param_number) value_is_null_ptr = FFI::MemoryPointer.new(:int) value = FFI::OGR::API.OGR_ST_GetParamDbl(@c_pointer, param_number, value_is_null_ptr) value_is_null_ptr.read_int.to_bool ? nil : value end |
#param_as_number(param_number) ⇒ Integer? Also known as: param_as_integer
72 73 74 75 76 77 |
# File 'lib/ogr/style_tool.rb', line 72 def param_as_number(param_number) value_is_null_ptr = FFI::MemoryPointer.new(:int) value = FFI::OGR::API.OGR_ST_GetParamNum(@c_pointer, param_number, value_is_null_ptr) value_is_null_ptr.read_int.to_bool ? nil : value end |
#param_as_string(param_number) ⇒ String?
89 90 91 92 93 94 95 |
# File 'lib/ogr/style_tool.rb', line 89 def param_as_string(param_number) value_is_null_ptr = FFI::MemoryPointer.new(:int) value, ptr = FFI::OGR::API.OGR_ST_GetParamStr(@c_pointer, param_number, value_is_null_ptr) ptr.autorelease = false value_is_null_ptr.read_int.to_bool ? nil : value end |
#rgb_from_string(color_string) ⇒ Hash{red => Integer, green => Integer, blue => Integer, alpha => Integer}
Returns the R, G, B, A components of a #RRGGBB formatted string.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ogr/style_tool.rb', line 107 def rgb_from_string(color_string) red_ptr = FFI::MemoryPointer.new(:int) green_ptr = FFI::MemoryPointer.new(:int) blue_ptr = FFI::MemoryPointer.new(:int) alpha_ptr = FFI::MemoryPointer.new(:int) boolean_result = FFI::OGR::API.OGR_ST_GetRGBFromString(@c_pointer, color_string, red_ptr, green_ptr, blue_ptr, alpha_ptr) if boolean_result { red: red_ptr.read_int, green: green_ptr.read_int, blue: blue_ptr.read_int, alpha: alpha_ptr.read_int } else { red: nil, green: nil, blue: nil, alpha: nil } end end |
#set_param_as_double(param_number, value) ⇒ Object Also known as: set_param_as_float
65 66 67 |
# File 'lib/ogr/style_tool.rb', line 65 def set_param_as_double(param_number, value) FFI::OGR::API.OGR_ST_SetParamDbl(@c_pointer, param_number, value) end |
#set_param_as_number(param_number, value) ⇒ Object Also known as: set_param_as_integer
82 83 84 |
# File 'lib/ogr/style_tool.rb', line 82 def set_param_as_number(param_number, value) FFI::OGR::API.OGR_ST_SetParamNum(@c_pointer, param_number, value) end |
#set_param_as_string(param_number, value) ⇒ Object
99 100 101 |
# File 'lib/ogr/style_tool.rb', line 99 def set_param_as_string(param_number, value) FFI::OGR::API.OGR_ST_SetParamStr(@c_pointer, param_number, value) end |
#set_unit(new_unit, ground_to_paper_scale) ⇒ Object
49 50 51 |
# File 'lib/ogr/style_tool.rb', line 49 def set_unit(new_unit, ground_to_paper_scale) FFI::OGR::API.OGR_ST_SetUnit(@c_pointer, new_unit, ground_to_paper_scale) end |
#style_string ⇒ String?
30 31 32 33 34 35 |
# File 'lib/ogr/style_tool.rb', line 30 def style_string style, ptr = FFI::OGR::API.OGR_ST_GetStyleString(@c_pointer) ptr.autorelease = false style end |
#type ⇒ FFI::OGR::Core::STClassId
38 39 40 |
# File 'lib/ogr/style_tool.rb', line 38 def type FFI::OGR::API.OGR_ST_GetType(@c_pointer) end |
#unit ⇒ FFI::OGR::Core::STUnitId
43 44 45 |
# File 'lib/ogr/style_tool.rb', line 43 def unit FFI::OGR::API.OGR_ST_GetUnit(@c_pointer) end |