Class: ScanBeacon::BlueZAdvertiser
- Inherits:
-
Object
- Object
- ScanBeacon::BlueZAdvertiser
- Defined in:
- lib/scan_beacon/bluez_advertiser.rb
Instance Attribute Summary collapse
-
#ad ⇒ Object
Returns the value of attribute ad.
-
#beacon ⇒ Object
Returns the value of attribute beacon.
-
#parser ⇒ Object
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ BlueZAdvertiser
constructor
A new instance of BlueZAdvertiser.
- #inspect ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #update_ad ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ BlueZAdvertiser
Returns a new instance of BlueZAdvertiser.
6 7 8 9 10 11 |
# File 'lib/scan_beacon/bluez_advertiser.rb', line 6 def initialize(opts = {}) @device_id = opts[:device_id] self.beacon = opts[:beacon] self.parser = opts[:parser] self.parser ||= BeaconParser.default_parsers.find {|parser| parser.beacon_type == beacon.beacon_types.first} end |
Instance Attribute Details
#ad ⇒ Object
Returns the value of attribute ad.
4 5 6 |
# File 'lib/scan_beacon/bluez_advertiser.rb', line 4 def ad @ad end |
#beacon ⇒ Object
Returns the value of attribute beacon.
4 5 6 |
# File 'lib/scan_beacon/bluez_advertiser.rb', line 4 def beacon @beacon end |
#parser ⇒ Object
Returns the value of attribute parser.
4 5 6 |
# File 'lib/scan_beacon/bluez_advertiser.rb', line 4 def parser @parser end |
Instance Method Details
#inspect ⇒ Object
36 37 38 |
# File 'lib/scan_beacon/bluez_advertiser.rb', line 36 def inspect "<BlueZAdvertiser ad=#{@ad.inspect}>" end |
#start ⇒ Object
28 29 30 |
# File 'lib/scan_beacon/bluez_advertiser.rb', line 28 def start BlueZ.start_advertising end |
#stop ⇒ Object
32 33 34 |
# File 'lib/scan_beacon/bluez_advertiser.rb', line 32 def stop BlueZ.stop_advertising end |
#update_ad ⇒ Object
40 41 42 |
# File 'lib/scan_beacon/bluez_advertiser.rb', line 40 def update_ad self.ad = @parser.generate_ad(@beacon) if @parser && @beacon end |