Class: ScanBeacon::BlueZAdvertiser

Inherits:
Object
  • Object
show all
Defined in:
lib/scan_beacon/bluez_advertiser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#adObject

Returns the value of attribute ad.



4
5
6
# File 'lib/scan_beacon/bluez_advertiser.rb', line 4

def ad
  @ad
end

#beaconObject

Returns the value of attribute beacon.



4
5
6
# File 'lib/scan_beacon/bluez_advertiser.rb', line 4

def beacon
  @beacon
end

#parserObject

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

#inspectObject



36
37
38
# File 'lib/scan_beacon/bluez_advertiser.rb', line 36

def inspect
  "<BlueZAdvertiser ad=#{@ad.inspect}>"
end

#startObject



28
29
30
# File 'lib/scan_beacon/bluez_advertiser.rb', line 28

def start
  BlueZ.start_advertising
end

#stopObject



32
33
34
# File 'lib/scan_beacon/bluez_advertiser.rb', line 32

def stop
  BlueZ.stop_advertising
end

#update_adObject



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