Class: Lorraine::CommandLine
- Inherits:
-
Thor
- Object
- Thor
- Lorraine::CommandLine
- Defined in:
- lib/lorraine/command.rb
Instance Method Summary collapse
- #debug ⇒ Object
- #interactive ⇒ Object
- #server(command) ⇒ Object
- #set(pixel, r, g, b) ⇒ Object
- #testpattern ⇒ Object
Instance Method Details
#debug ⇒ Object
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 |
#interactive ⇒ Object
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() while true response = ask(">> ") if response == "exit" break elsif response.include?("effect") if response.include?("off") c. Lorraine::Message.new(:effect, 0) else c. 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 = (response.split(" ")) c. m c. 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([: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() m = [pixel, r, g, b] c. m c. Lorraine::Message.new(:refresh) end |
#testpattern ⇒ Object
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 |