Skip to content

Instantly share code, notes, and snippets.

@ohnishiakira
Created March 29, 2011 17:58
Show Gist options
  • Save ohnishiakira/892874 to your computer and use it in GitHub Desktop.
Save ohnishiakira/892874 to your computer and use it in GitHub Desktop.
Generating machine unreadable word.
#!/usr/bin/env ruby
# coding: utf-8
class AvoidSearch
Delimiter = "!\"#\$%&'()-=^~\|@`[{;+:*]},<.>/?\\_"
def initialize(word="", sym="")
@word = word.split(//)
@sym = sym
end
def delimiter
@sym != "" ? @sym : Delimiter[(rand * 100) % Delimiter.length]
end
def spam
result = @word.shift
@word.each do |w|
result += self.delimiter + w
end
result
end
end
word = "もふもふ"
sym = "もふ"
case ARGV.length
when 1
word = ARGV[0]
when 2
word = ARGV[0]
sym = ARGV[1]
end
# example
a = AvoidSearch.new(word, sym)
puts a.spam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment