Class: Motionscan::Scanner
- Inherits:
-
Object
- Object
- Motionscan::Scanner
- Includes:
- Flash
- Defined in:
- lib/motionscan/scanner.rb
Instance Attribute Summary collapse
-
#flashEnabled ⇒ Object
Returns the value of attribute flashEnabled.
-
#frame ⇒ Object
Returns the value of attribute frame.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Class Method Summary collapse
Instance Method Summary collapse
- #displayScannerInView(view) ⇒ Object
- #pause ⇒ Object
- #resume ⇒ Object
- #scannerInitializer(frame) ⇒ Object
- #searchWithStatus(searchStarted, success: searchCompleted, error: searchError, notFound: searchNotFound) ⇒ Object
-
#startWithStatus(scanStarted, success: scanCompleted, error: scanError, notFound: scanNotFound) ⇒ Object
scanner session flow.
- #stop ⇒ Object
Methods included from Flash
Instance Attribute Details
#flashEnabled ⇒ Object
Returns the value of attribute flashEnabled.
5 6 7 |
# File 'lib/motionscan/scanner.rb', line 5 def flashEnabled @flashEnabled end |
#frame ⇒ Object
Returns the value of attribute frame.
6 7 8 |
# File 'lib/motionscan/scanner.rb', line 6 def frame @frame end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
8 9 10 |
# File 'lib/motionscan/scanner.rb', line 8 def view @view end |
Class Method Details
.initWithFrame(frame) ⇒ Object
10 11 12 13 14 |
# File 'lib/motionscan/scanner.rb', line 10 def self.initWithFrame(frame) instance = allocate instance.scannerInitializer(frame) instance end |
Instance Method Details
#displayScannerInView(view) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/motionscan/scanner.rb', line 26 def displayScannerInView(view) @session = MSScannerSession.alloc.initWithScanner(MSScanner.sharedInstance) @session.scanOptions = MS_RESULT_TYPE_IMAGE @session.delegate = self @view.backgroundColor = UIColor.blackColor @view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight @view.autoresizesSubviews = true view.addSubview(@view) end |
#pause ⇒ Object
66 67 68 |
# File 'lib/motionscan/scanner.rb', line 66 def pause @session.pause end |
#resume ⇒ Object
62 63 64 |
# File 'lib/motionscan/scanner.rb', line 62 def resume @session.resume end |
#scannerInitializer(frame) ⇒ Object
16 17 18 19 20 |
# File 'lib/motionscan/scanner.rb', line 16 def scannerInitializer(frame) @frame = frame @flashEnabled = true @view = UIView.alloc.initWithFrame(frame) end |
#searchWithStatus(searchStarted, success: searchCompleted, error: searchError, notFound: searchNotFound) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/motionscan/scanner.rb', line 70 def searchWithStatus(searchStarted, success:searchCompleted,error:searchError,notFound:searchNotFound) @searchStarted = searchStarted @searchCompleted = searchCompleted @searchError = searchError @searchNotFound = searchNotFound self.flash if @flashEnabled @session.snap @session.pause end |
#startWithStatus(scanStarted, success: scanCompleted, error: scanError, notFound: scanNotFound) ⇒ Object
scanner session flow
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/motionscan/scanner.rb', line 38 def startWithStatus(scanStarted, success:scanCompleted, error:scanError, notFound:scanNotFound) scanStarted.call @scanCompleted = scanCompleted @scanError = scanError @scanNotFound = scanNotFound viewLayer = @view.layer viewLayer.setMasksToBounds(true) captureLayer = @session.previewLayer captureLayer.setFrame(@view.bounds) viewLayer.insertSublayer(captureLayer, below:viewLayer.sublayers) @session.startCapture end |
#stop ⇒ Object
56 57 58 59 60 |
# File 'lib/motionscan/scanner.rb', line 56 def stop @session.stopCapture @session.cancel @view.removeFromSuperview end |