Class: Lorraine::CommandLine

Inherits:
Thor
  • Object
show all
Defined in:
lib/lorraine/command.rb

Instance Method Summary collapse

Instance Method Details

#debugObject



68
69
70
71
72
73
# File 'lib/lorraine/command.rb', line 68

def debug
  c = Lorraine::Message.new :set_pixel, 2, 0, 0, 4095
  j = c.to_json
  puts "json: #{j}"
  puts Lorraine::Message.from_json j
end

#interactiveObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/lorraine/command.rb', line 42

def interactive
  c = open_connection(options)
  while true
    response = ask(">> ")
    if response == "exit"
      break
    elsif response.include?("effect")
      if response.include?("off")
        c.write_message Lorraine::Message.new(:effect, 0)
      else
        c.write_message Lorraine::Message.new(:effect, response.split(" ")[1].to_i)
      end
    elsif response == "defcon"
      defcon = Lorraine::Image.new(5, 1)
      defcon.rgb_pixels = [[1, 0, 0], [1, 0.2, 0], [1, 1, 0], [0, 0, 1], [0, 1, 0]]
      c.display_image defcon
    else
      m = message_from_console_array(response.split(" "))
      c.write_message m
      c.write_message Lorraine::Message.new(:refresh)
    end
  end
end

#server(command) ⇒ Object



19
20
21
22
23
24
# File 'lib/lorraine/command.rb', line 19

def server(command)
  puts "command: #{command}, options: #{options}"
  if command.to_sym == :start
    Lorraine::Server.start(options[:port])
  end
end

#set(pixel, r, g, b) ⇒ Object



30
31
32
33
34
35
# File 'lib/lorraine/command.rb', line 30

def set(pixel, r, g, b)
  c = open_connection(options)
  m = message_from_console_array [pixel, r, g, b]
  c.write_message m
  c.write_message Lorraine::Message.new(:refresh)
end

#testpatternObject



9
10
11
12
13
14
15
# File 'lib/lorraine/command.rb', line 9

def testpattern
  say "nice to meet you", :red
  ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])

  
  puts "I'm a thor task!"
end