Class: Geppeto::Scout
- Inherits:
-
Object
- Object
- Geppeto::Scout
- Defined in:
- lib/scout.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#hq ⇒ Object
readonly
Returns the value of attribute hq.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_report ⇒ Object
Returns the value of attribute last_report.
-
#led ⇒ Object
readonly
Returns the value of attribute led.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#memory ⇒ Object
readonly
Returns the value of attribute memory.
-
#mesh ⇒ Object
readonly
Returns the value of attribute mesh.
-
#pin ⇒ Object
readonly
Returns the value of attribute pin.
-
#power ⇒ Object
readonly
Returns the value of attribute power.
-
#temperature ⇒ Object
readonly
Returns the value of attribute temperature.
-
#uptime ⇒ Object
readonly
Returns the value of attribute uptime.
-
#wifi ⇒ Object
readonly
Returns the value of attribute wifi.
Instance Method Summary collapse
- #all ⇒ Object
- #boot ⇒ Object
- #delay(ms = nil) ⇒ Object
-
#initialize(connection, id = nil) ⇒ Scout
constructor
A new instance of Scout.
- #lead? ⇒ Boolean
- #others ⇒ Object
- #randomnumber ⇒ Object
- #report ⇒ Object
- #request(command, *args, ms: nil) ⇒ Object
Constructor Details
#initialize(connection, id = nil) ⇒ Scout
Returns a new instance of Scout.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/scout.rb', line 18 def initialize(connection, id = nil) @id = id @conn = connection @options = Array.new @logger = @conn.logger ? @conn.logger : Logger.new(STDOUT) @events = Geppeto::Commands::Events.new(self) @hq = Geppeto::Commands::Hq.new(self) @led = Geppeto::Commands::Led.new(self) @memory = Geppeto::Commands::Memory.new(self) @mesh = Geppeto::Commands::Mesh.new(self) @pin = Geppeto::Commands::Pin.new(self) @power = Geppeto::Commands::Power.new(self) @uptime = Geppeto::Commands::Uptime.new(self) @wifi = Geppeto::Commands::Wifi.new(self) end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
7 8 9 |
# File 'lib/scout.rb', line 7 def events @events end |
#hq ⇒ Object (readonly)
Returns the value of attribute hq.
8 9 10 |
# File 'lib/scout.rb', line 8 def hq @hq end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/scout.rb', line 3 def id @id end |
#last_report ⇒ Object
Returns the value of attribute last_report.
4 5 6 |
# File 'lib/scout.rb', line 4 def last_report @last_report end |
#led ⇒ Object (readonly)
Returns the value of attribute led.
9 10 11 |
# File 'lib/scout.rb', line 9 def led @led end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/scout.rb', line 5 def logger @logger end |
#memory ⇒ Object (readonly)
Returns the value of attribute memory.
10 11 12 |
# File 'lib/scout.rb', line 10 def memory @memory end |
#mesh ⇒ Object (readonly)
Returns the value of attribute mesh.
11 12 13 |
# File 'lib/scout.rb', line 11 def mesh @mesh end |
#pin ⇒ Object (readonly)
Returns the value of attribute pin.
12 13 14 |
# File 'lib/scout.rb', line 12 def pin @pin end |
#power ⇒ Object (readonly)
Returns the value of attribute power.
13 14 15 |
# File 'lib/scout.rb', line 13 def power @power end |
#temperature ⇒ Object (readonly)
Returns the value of attribute temperature.
14 15 16 |
# File 'lib/scout.rb', line 14 def temperature @temperature end |
#uptime ⇒ Object (readonly)
Returns the value of attribute uptime.
15 16 17 |
# File 'lib/scout.rb', line 15 def uptime @uptime end |
#wifi ⇒ Object (readonly)
Returns the value of attribute wifi.
16 17 18 |
# File 'lib/scout.rb', line 16 def wifi @wifi end |
Instance Method Details
#all ⇒ Object
35 36 37 38 |
# File 'lib/scout.rb', line 35 def all @options << :all self end |
#boot ⇒ Object
65 66 67 |
# File 'lib/scout.rb', line 65 def boot request("scout.boot") end |
#delay(ms = nil) ⇒ Object
59 60 61 62 63 |
# File 'lib/scout.rb', line 59 def delay(ms = nil) @options << :delay @_ms = ms self end |
#lead? ⇒ Boolean
49 50 51 |
# File 'lib/scout.rb', line 49 def lead? request("print scout.isleadscout").to_i == 1 end |
#others ⇒ Object
40 41 42 43 |
# File 'lib/scout.rb', line 40 def others @options << :others self end |
#randomnumber ⇒ Object
53 54 55 |
# File 'lib/scout.rb', line 53 def randomnumber request("randomnumber") end |
#report ⇒ Object
45 46 47 |
# File 'lib/scout.rb', line 45 def report request("scout.report") end |
#request(command, *args, ms: nil) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/scout.rb', line 69 def request(command, *args, ms: nil) args_string = join_args(args) command, args_string = (command, args_string) if args_string.empty? unless @id.nil? command = "command.scout(#{@id}, \"#{command}\")" else command = "#{command}()" end else unless @id.nil? command = "command.scout(#{@id}, \"#{command}\", #{args_string})" else command = "#{command}(#{args_string})" end end @logger.debug("Issuing: #{command}") @conn.write(command, ms) end |