Created
May 18, 2010 13:24
-
-
Save udonchan/404987 to your computer and use it in GitHub Desktop.
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 -*- | |
require 'net/http' | |
require 'uri' | |
Net::HTTP.version_1_2 | |
class Shindan | |
def initialize(arr) | |
@arr = arr | |
end | |
def twitter_user?(usr) | |
Net::HTTP.get_response(URI.parse("http://twitter.com/" + usr)).code == '200' | |
end | |
def result(usr) | |
raise ArgumentError, 'user not found' unless twitter_user?(usr) | |
@arr[usr.hash % @arr.size] | |
end | |
end | |
exit 1 unless ARGV[0] | |
puts ARGV[0] + "さんの嫁は" + Shindan.new(['真田アサミ', '沢城みゆき', '氷上恭子', '林原めぐみ']).result(ARGV[0]) + "です." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment