Class: CLBeaconRegion
- Inherits:
-
Object
- Object
- CLBeaconRegion
- Defined in:
- lib/motion-beacon/clbeaconregion.rb
Overview
extended BeaconRegion class with list of beacons and helper methods
Instance Attribute Summary collapse
-
#beacons ⇒ Object
Returns the value of attribute beacons.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
Instance Attribute Details
#beacons ⇒ Object
Returns the value of attribute beacons.
4 5 6 |
# File 'lib/motion-beacon/clbeaconregion.rb', line 4 def beacons @beacons end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/motion-beacon/clbeaconregion.rb', line 5 def timeout @timeout end |
Instance Method Details
#distance ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/motion-beacon/clbeaconregion.rb', line 7 def distance if @beacons.empty? then return 99999 else beaconMin = @beacons.min { |a, b| a.accuracy <=> b.accuracy } beaconMin.accuracy end end |
#hasBeacon?(major, minor) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/motion-beacon/clbeaconregion.rb', line 16 def hasBeacon?(major, minor) @beacons.each { |beacon| if not major.nil? then if minor.nil? then if beacon.major == major then return true end else if beacon.major == major and beacon.minor == minor then return true end end end } false end |
#printBeacons ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/motion-beacon/clbeaconregion.rb', line 38 def printBeacons @beacons.each { |beacon| NSLog("beacon: [major]: " + beacon.major.to_s + " [minor]: " + beacon.minor.to_s + " [proximity]: " + beacon.proximity.to_s + " [accuracy]: " + beacon.accuracy.to_s + " [rssi]: " + beacon.rssi.to_s) } end |
#to_s ⇒ Object
33 34 35 36 |
# File 'lib/motion-beacon/clbeaconregion.rb', line 33 def to_s "region: [major]: " + major.to_s + " [minor]: " + minor.to_s end |