Class: Tesseract::API::Iterator
- Inherits:
-
Object
- Object
- Tesseract::API::Iterator
- Defined in:
- lib/tesseract/api/iterator.rb
Class Method Summary collapse
-
.finalize(pointer) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #baseline(level = :word) ⇒ Object
- #begin ⇒ Object
- #beginning?(level = :word) ⇒ Boolean
- #block_type ⇒ Object
- #bounding_box(level = :word) ⇒ Object
- #confidence(level = :word) ⇒ Object
- #end?(level, element) ⇒ Boolean
- #get_binary_image(level = :word) ⇒ Object
- #get_image(level = :word, padding = 0) ⇒ Object
- #get_text(level = :word) ⇒ Object
-
#initialize(pointer) ⇒ Iterator
constructor
A new instance of Iterator.
- #next(level = :word) ⇒ Object
- #orientation ⇒ Object
- #symbol_is_dropcap? ⇒ Boolean
- #symbol_is_subscript? ⇒ Boolean
- #symbol_is_superscript? ⇒ Boolean
- #to_ffi ⇒ Object
- #word_font_attributes ⇒ Object
- #word_is_from_dictionary? ⇒ Boolean
- #word_is_numeric? ⇒ Boolean
Constructor Details
#initialize(pointer) ⇒ Iterator
Returns a new instance of Iterator.
28 29 30 31 32 |
# File 'lib/tesseract/api/iterator.rb', line 28 def initialize (pointer) raise ArgumentError, 'the pointer is null' if pointer.nil? || pointer.null? @internal = FFI::AutoPointer.new(pointer, self.class.method(:finalize)) end |
Class Method Details
.finalize(pointer) ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/tesseract/api/iterator.rb', line 34 def self.finalize (pointer) # :nodoc: C::Iterator.destroy(pointer) end |
Instance Method Details
#baseline(level = :word) ⇒ Object
68 69 70 |
# File 'lib/tesseract/api/iterator.rb', line 68 def baseline (level = :word) C::Iterator.baseline(to_ffi, C.for_enum(level)) end |
#begin ⇒ Object
38 39 40 |
# File 'lib/tesseract/api/iterator.rb', line 38 def begin C::Iterator.begin(to_ffi) end |
#beginning?(level = :word) ⇒ Boolean
42 43 44 |
# File 'lib/tesseract/api/iterator.rb', line 42 def beginning? (level = :word) C::Iterator.is_at_beginning_of(to_ffi, C.for_enum(level)) end |
#block_type ⇒ Object
93 94 95 |
# File 'lib/tesseract/api/iterator.rb', line 93 def block_type C::Iterator.block_type(to_ffi) end |
#bounding_box(level = :word) ⇒ Object
54 55 56 |
# File 'lib/tesseract/api/iterator.rb', line 54 def bounding_box (level = :word) C::Iterator.bounding_box(to_ffi, C.for_enum(level)) end |
#confidence(level = :word) ⇒ Object
89 90 91 |
# File 'lib/tesseract/api/iterator.rb', line 89 def confidence (level = :word) C::Iterator.confidence(to_ffi, C.for_enum(level)) end |
#end?(level, element) ⇒ Boolean
46 47 48 |
# File 'lib/tesseract/api/iterator.rb', line 46 def end? (level, element) C::Iterator.is_at_final_element(to_ffi, C.for_enum(level), C.for_enum(element)) end |
#get_binary_image(level = :word) ⇒ Object
58 59 60 |
# File 'lib/tesseract/api/iterator.rb', line 58 def get_binary_image (level = :word) Image.new(C::Iterator.get_binary_image(to_ffi, C.for_enum(level))) end |
#get_image(level = :word, padding = 0) ⇒ Object
62 63 64 65 66 |
# File 'lib/tesseract/api/iterator.rb', line 62 def get_image (level = :word, padding = 0) image = C::Iterator.get_image(to_ffi, C.for_enum(level), padding) Image.new(image[:pix], image[:x], image[:y]) end |
#get_text(level = :word) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/tesseract/api/iterator.rb', line 76 def get_text (level = :word) pointer = C::Iterator.get_utf8_text(to_ffi, C.for_enum(level)) return if pointer.null? result = pointer.read_string result.force_encoding 'UTF-8' result ensure C.free_array_of_char(pointer) unless pointer.null? end |
#next(level = :word) ⇒ Object
50 51 52 |
# File 'lib/tesseract/api/iterator.rb', line 50 def next (level = :word) C::Iterator.next(to_ffi, C.for_enum(level)) end |
#orientation ⇒ Object
72 73 74 |
# File 'lib/tesseract/api/iterator.rb', line 72 def orientation C::Iterator.orientation(to_ffi) end |
#symbol_is_dropcap? ⇒ Boolean
117 118 119 |
# File 'lib/tesseract/api/iterator.rb', line 117 def symbol_is_dropcap? C::Iterator.symbol_is_dropcap(to_ffi) end |
#symbol_is_subscript? ⇒ Boolean
113 114 115 |
# File 'lib/tesseract/api/iterator.rb', line 113 def symbol_is_subscript? C::Iterator.symbol_is_subscript(to_ffi) end |
#symbol_is_superscript? ⇒ Boolean
109 110 111 |
# File 'lib/tesseract/api/iterator.rb', line 109 def symbol_is_superscript? C::Iterator.symbol_is_superscript(to_ffi) end |
#to_ffi ⇒ Object
121 122 123 |
# File 'lib/tesseract/api/iterator.rb', line 121 def to_ffi @internal end |
#word_font_attributes ⇒ Object
97 98 99 |
# File 'lib/tesseract/api/iterator.rb', line 97 def word_font_attributes C::Iterator.word_font_attributes(to_ffi) end |
#word_is_from_dictionary? ⇒ Boolean
101 102 103 |
# File 'lib/tesseract/api/iterator.rb', line 101 def word_is_from_dictionary? C::Iterator.word_is_from_dictionary(to_ffi) end |
#word_is_numeric? ⇒ Boolean
105 106 107 |
# File 'lib/tesseract/api/iterator.rb', line 105 def word_is_numeric? C::Iterator.word_is_numeric(to_ffi) end |