Class: RubyPager::Text_Region
- Inherits:
-
Object
- Object
- RubyPager::Text_Region
- Defined in:
- lib/ruby_pager/text_region.rb
Instance Attribute Summary collapse
-
#contour ⇒ Object
readonly
Returns the value of attribute contour.
-
#custom ⇒ Object
readonly
Returns the value of attribute custom.
-
#id ⇒ Object
Returns the value of attribute id.
-
#index ⇒ Object
Returns the value of attribute index.
Class Method Summary collapse
Instance Method Summary collapse
- #[](ex_key) ⇒ Object
- #baseline_vertical_noise(ex_std_dev) ⇒ Object
- #clear_text_lines ⇒ Object
- #delete(ex_line_id) ⇒ Object
- #get_consolidated_data ⇒ Object
- #has_line?(line_id) ⇒ Boolean
-
#initialize(ex_index, ex_data) ⇒ Text_Region
constructor
A new instance of Text_Region.
- #push(ex_line) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(ex_index, ex_data) ⇒ Text_Region
Returns a new instance of Text_Region.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ruby_pager/text_region.rb', line 6 def initialize(ex_index, ex_data) @logger = Utils::ApplicationLogger.instance @data=ex_data @index=ex_index @id = @data["@id"] @custom=@data["@custom"] @text_lines=Hash.new load_text_lines() load_contour() end |
Instance Attribute Details
#contour ⇒ Object (readonly)
Returns the value of attribute contour.
5 6 7 |
# File 'lib/ruby_pager/text_region.rb', line 5 def contour @contour end |
#custom ⇒ Object (readonly)
Returns the value of attribute custom.
5 6 7 |
# File 'lib/ruby_pager/text_region.rb', line 5 def custom @custom end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/ruby_pager/text_region.rb', line 5 def id @id end |
#index ⇒ Object
Returns the value of attribute index.
5 6 7 |
# File 'lib/ruby_pager/text_region.rb', line 5 def index @index end |
Class Method Details
.blank ⇒ Object
17 18 19 |
# File 'lib/ruby_pager/text_region.rb', line 17 def self.blank return Text_Region.new(0,Text_Region.blank_data) end |
.blank_data ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/ruby_pager/text_region.rb', line 71 def self.blank_data res=Hash.new res["@id"]="" res["@custom"]="" res["TextLine"]=Array.new res["Coords"]=Hash.new res["Coords"]["@points"]=Coords.blank_data return res end |
Instance Method Details
#[](ex_key) ⇒ Object
35 36 37 38 |
# File 'lib/ruby_pager/text_region.rb', line 35 def [](ex_key) raise(RangeError, "Index #{ex_key} is out of range") unless @text_lines.has_key? ex_key return @text_lines[ex_key] end |
#baseline_vertical_noise(ex_std_dev) ⇒ Object
81 82 83 |
# File 'lib/ruby_pager/text_region.rb', line 81 def baseline_vertical_noise(ex_std_dev) @text_lines.values.each {|text_line| text_line.baseline_vertical_noise(ex_std_dev) } end |
#clear_text_lines ⇒ Object
54 55 56 |
# File 'lib/ruby_pager/text_region.rb', line 54 def clear_text_lines() @text_lines.clear end |
#delete(ex_line_id) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/ruby_pager/text_region.rb', line 44 def delete(ex_line_id) if has_line? ex_line_id @logger.info("Deleting text region #{ex_line_id}") @text_lines.delete(ex_line_id) review_lines_index else raise(ArgumentError, "Line id #{ex_line_id} does not exist so it can not be deleted") end end |
#get_consolidated_data ⇒ Object
66 67 68 69 |
# File 'lib/ruby_pager/text_region.rb', line 66 def get_consolidated_data consolidate_data() return @data end |
#has_line?(line_id) ⇒ Boolean
40 41 42 |
# File 'lib/ruby_pager/text_region.rb', line 40 def has_line? line_id return @text_lines.has_key? line_id end |
#push(ex_line) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/ruby_pager/text_region.rb', line 58 def push(ex_line) raise(ArgumentError, "Got passed a non text line object") if ex_line.class != RubyPager::Text_Line raise(ArgumentError, "Text line id already in use") if @text_lines.has_key? ex_line.id ex_line.index=@text_lines.size @text_lines[ex_line.id]=ex_line end |
#size ⇒ Object
21 22 23 |
# File 'lib/ruby_pager/text_region.rb', line 21 def size return @text_lines.size end |