Created
March 29, 2011 17:58
-
-
Save ohnishiakira/892874 to your computer and use it in GitHub Desktop.
Generating machine unreadable word.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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