class LZRTag::Map::Set
Attributes
centerpoint[RW]
zones[R]
Public Class Methods
new(mqtt, zones = Array.new())
click to toggle source
# File lib/lzrtag/map/map_set.rb, line 12 def initialize(mqtt, zones = Array.new()) @mqtt = mqtt; @zones = zones; @centerpoint = Array.new(); end
Public Instance Methods
clear()
click to toggle source
# File lib/lzrtag/map/map_set.rb, line 43 def clear() @mqtt.publish_to "Lasertag/Game/Zones", "", retain: true; end
publish()
click to toggle source
# File lib/lzrtag/map/map_set.rb, line 40 def publish() @mqtt.publish_to "Lasertag/Zones", self.to_json, qos: 1, retain: true; end
to_h()
click to toggle source
# File lib/lzrtag/map/map_set.rb, line 19 def to_h() outData = Hash.new(); if(@centerpoint.length != 3) raise ArgumentError, "Center point needs to be set!" end outData[:centerpoint] = @centerpoint outData[:zones] = Array.new(); @zones.each do |z| outData[:zones] << z.to_h; end return outData; end
to_json()
click to toggle source
# File lib/lzrtag/map/map_set.rb, line 36 def to_json() return self.to_h().to_json(); end