Method: Roi#initialize
- Defined in:
- lib/roi/roi.rb
#initialize(dut, args = {}) ⇒ Roi
Public: Initializes a base Roi.
dut - Platform (or subclass) instance to which this Roi belongs. x - Integer x coordinate (default: nil). y - Integer y coordinate (default: nil). width - Integer width (default: nil). height - Integer height (default: nil). rectangle - Hash defining rectangle with keys :x, :y, :width, :height (default: nil). element - Hash same as rectangle (default: nil). ref_img - String path to reference image (default: nil).
Returns nothing.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/roi/roi.rb', line 23 def initialize(dut, args={}) @name = nil # Determine ROI name. This will be the first method that calls `new'. stack = caller last_end = stack.each_index.select do |i| stack[i].end_with?("in `new'") end.last unless last_end.nil? match = stack[last_end + 1].match(/`(\w+)'/) unless match.nil? @name = match[1] unless match[1] == 'run' # ignore dynamic ROIs end end if args.include?(:element) self.rectangle=args[:element] else self.rectangle=(args.fetch(:rectangle, args)) # Get x, y, width, and height from rectangle (if provided) or args end @ref_img = args.fetch(:ref_img, '') @dut = dut # These are declared without the convenience methods (TMC monkey patching) so as not to break syntax evaluation. @priorities = { :critical => 0.01, :high => 0.1, :normal => 1, :low => 10, :background => 60 } end |