Skip to content

Instantly share code, notes, and snippets.

@burtlo
Created August 24, 2011 03:56
Show Gist options
  • Save burtlo/1167274 to your computer and use it in GitHub Desktop.
Save burtlo/1167274 to your computer and use it in GitHub Desktop.
Interact with the sign brought by @tenderlove
require 'drb/drb'
require 'betabrite'
SERVER_URI = "druby://192.168.1.172:8787"
DRb.start_service
def S(str)
BetaBrite::String.new(str)
end
def sw(message, *option)
# Ensure our options are a nice flat array
option = Array(option).flatten
# Show a little information to the user
puts "Writing: #{message} with options #{option.join(",")}"
# This is our templating language to save having to type in the characters
# They are accessible numerically. Not pretty but works...
# https://github.com/tenderlove/betabrite/blob/master/lib/betabrite/string.rb
message.scan(/!!(\d+)/).each do |match|
puts "Swapping in symbol: #{BetaBrite::String.constants[match.flatten.first.to_i]}"
message.gsub!("!!#{match.flatten.first}",eval("BetaBrite::String::#{BetaBrite::String.constants[match.flatten.first.to_i]}") )
end
# Perform all the transformations (e.g. seven_shadow, rainbow_2)
string = S(message)
string = option.inject(string) {|memo,obj| memo.send(obj) ; memo }
# Connect and write the raw message
sign = DRbObject.new_with_uri(SERVER_URI)
sign.write_raw [ string ]
end
sw "!!8tenderlove!!8", :seven_shadow, :rainbow_2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment