Class: Sqed
- Inherits:
-
Object
- Object
- Sqed
- Defined in:
- lib/sqed.rb,
lib/sqed/result.rb,
lib/sqed/version.rb,
lib/sqed/extractor.rb,
lib/sqed/boundaries.rb,
lib/sqed/boundary_finder.rb
Overview
Instances take the following 1) An :image @image 2) A target extraction pattern, or individually specified attributes
Return a Sqed::Result
a = Sqed.new(pattern: :vertical_offset_cross, image: image)
b = a.result # => Sqed::Result instance
Defined Under Namespace
Classes: Boundaries, BoundaryFinder, Extractor, Parser, Result
Constant Summary collapse
- VERSION =
'0.5.2'.freeze
Instance Attribute Summary collapse
-
#boundaries(force = false) ⇒ Sqed::Boundaries instance
Contains the coordinates of the internal stage sections.
-
#boundary_color ⇒ Symbol
describing the boundary color within the stage.
-
#boundary_finder ⇒ Object
Provide a boundary_finder, overrides metadata taken from pattern.
-
#has_border ⇒ Boolean
Defaults to ‘true` when true detects border on initialization.
-
#image ⇒ Object
initial image which is an instance of ImageMagick::Image, containing background and stage, or just stage.
-
#layout ⇒ Symbol
!! Provide a specific layout, passed as option :layout, overrides layout metadata taken from :pattern, defaults to ‘:cross`.
-
#metadata_map ⇒ Object
Provide a metadata map, overrides metadata taken from pattern.
-
#pattern ⇒ Symbol
!optional! A lookup macro that if provided sets boundary_finder, layout, and metadata_map.
-
#stage_boundary ⇒ Sqed::Boundaries instance
Stores the coordinates of the stage.
-
#stage_image ⇒ Object
the image that is the cropped content for parsing.
-
#use_thumbnail ⇒ Boolean
against a thumbnail version of the passed image.
Instance Method Summary collapse
-
#attributes ⇒ Hash
An overview of data/metadata, for debugging purposes only.
-
#crop_image ⇒ Image
Crops the stage if not done, then sets/returns @stage_image.
-
#extraction_metadata ⇒ Hash
Federate extraction options.
-
#initialize(**opts) ⇒ Sqed
constructor
A new instance of Sqed.
-
#native_boundaries ⇒ Sqed::Boundaries instance?
A boundaries instance that has the original image (prior to cropping stage) coordinates.
- #result ⇒ Object
Constructor Details
#initialize(**opts) ⇒ Sqed
Returns a new instance of Sqed.
74 75 76 77 78 79 80 |
# File 'lib/sqed.rb', line 74 def initialize(**opts) # extraction metadata @image = opts[:image] configure(opts) stub_results end |
Instance Attribute Details
#boundaries(force = false) ⇒ Sqed::Boundaries instance
Returns contains the coordinates of the internal stage sections.
53 54 55 |
# File 'lib/sqed.rb', line 53 def boundaries @boundaries end |
#boundary_color ⇒ Symbol
describing the boundary color within the stage
61 62 63 |
# File 'lib/sqed.rb', line 61 def boundary_color @boundary_color end |
#boundary_finder ⇒ Object
Provide a boundary_finder, overrides metadata taken from pattern
72 73 74 |
# File 'lib/sqed.rb', line 72 def boundary_finder @boundary_finder end |
#has_border ⇒ Boolean
Returns defaults to ‘true` when true detects border on initialization.
57 58 59 |
# File 'lib/sqed.rb', line 57 def has_border @has_border end |
#image ⇒ Object
initial image which is an instance of ImageMagick::Image, containing background and stage, or just stage
25 26 27 |
# File 'lib/sqed.rb', line 25 def image @image end |
#layout ⇒ Symbol
!! Provide a specific layout, passed as option :layout, overrides layout metadata taken from :pattern, defaults to ‘:cross`
42 43 44 |
# File 'lib/sqed.rb', line 42 def layout @layout end |
#metadata_map ⇒ Object
Provide a metadata map, overrides metadata taken from pattern
69 70 71 |
# File 'lib/sqed.rb', line 69 def @metadata_map end |
#pattern ⇒ Symbol
!optional! A lookup macro that if provided sets boundary_finder, layout, and metadata_map. These can be individually overwritten. Legal values are symbols taken from SqedConfig::EXTRACTION_PATTERNS.
!! Patterns are not intended to be persisted in external databases (they may change names). !! To persist Sqed metadata in something like Postgres reference individual attributes (e.g. layout, metadata_map, boundary_finder).
default value is ‘nil`
not required if layout, metadata_map, and boundary_finder are provided
38 39 40 |
# File 'lib/sqed.rb', line 38 def pattern @pattern end |
#stage_boundary ⇒ Sqed::Boundaries instance
Returns stores the coordinates of the stage.
49 50 51 |
# File 'lib/sqed.rb', line 49 def stage_boundary @stage_boundary end |
#stage_image ⇒ Object
the image that is the cropped content for parsing
45 46 47 |
# File 'lib/sqed.rb', line 45 def stage_image @stage_image end |
#use_thumbnail ⇒ Boolean
against a thumbnail version of the passed image
66 67 68 |
# File 'lib/sqed.rb', line 66 def use_thumbnail @use_thumbnail end |
Instance Method Details
#attributes ⇒ Hash
Returns an overview of data/metadata, for debugging purposes only.
153 154 155 156 157 158 |
# File 'lib/sqed.rb', line 153 def attributes { image: image, boundaries: boundaries, stage_boundary: stage_boundary }.merge!() end |
#crop_image ⇒ Image
Returns crops the stage if not done, then sets/returns @stage_image.
130 131 132 133 134 135 136 137 |
# File 'lib/sqed.rb', line 130 def crop_image if has_border @stage_image = image.crop(*stage_boundary.for(SqedConfig.index_for_section_type(:stage, :stage)), true) else @stage_image = image end @stage_image end |
#extraction_metadata ⇒ Hash
Returns federate extraction options.
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/sqed.rb', line 84 def { boundary_finder: boundary_finder, layout: layout, metadata_map: , boundary_color: boundary_color, has_border: has_border, use_thumbnail: use_thumbnail } end |
#native_boundaries ⇒ Sqed::Boundaries instance?
Returns a boundaries instance that has the original image (prior to cropping stage) coordinates.
120 121 122 123 124 125 126 |
# File 'lib/sqed.rb', line 120 def native_boundaries if @boundaries.complete @boundaries.offset(stage_boundary) else nil end end |