ruby @quickleft #hackfest代码为MakeyMakey到Twilio

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby @quickleft #hackfest代码为MakeyMakey到Twilio相关的知识,希望对你有一定的参考价值。

# encoding: utf-8

require 'rubygems' # not necessary with ruby 1.9 but included for completeness
require 'twilio-ruby'
# put your own credentials here
              
account_sid = 'ABCABCABCABCABCABCABCABCABCABCABC'#GET YOUR OWN TOKENS FROM TWILIO
auth_token = 'ABCABCABCABCABCABCABCABCABCABCABC' #GET YOUR OWN TOKENS FROM TWILIO

# set up a client to talk to the Twilio REST API
@client = Twilio::REST::Client.new account_sid, auth_token


def text(message = 'BOOM')
  @client.account.messages.create(
    :from => '+18885551212', #GET YOUR OWN NUMBER FROM TWILIO
    :to => '+13335251234', #VERIFY YOUR PHONE NUMBER TO TWILIO
    :body => message)
end

@previous_level = :empty
def handle_input(input)
  if @previous_level == input
  else
    @previous_level = input
    new_input(input)
  end
end

def new_input(input)
  case input
  when 'w'
    text('The glass is full!')
  when 's'
    text('The glass is half full')
  when 'a'
    text('The glass is almost empty')
  else
    text("some DIRT")
  end
end

begin
  system("stty raw -echo")
  loop do
    handle_input STDIN.getc
  end
ensure
  system("stty -raw echo")
end

以上是关于ruby @quickleft #hackfest代码为MakeyMakey到Twilio的主要内容,如果未能解决你的问题,请参考以下文章

Jenkins Hackfest 用户体验文档报告

ruby [Ruby Cheat] Cheatsheet #ruby

Ruby运算符

Ruby 25 岁了!Ruby 之父说 Ruby 3 有望 3 倍提速

如何学习ruby?Ruby学习技巧分享

ruby Ruby脚本,看看是否用openssl编译了ruby