Skip to content

Instantly share code, notes, and snippets.

@udonchan
Created May 18, 2010 13:24
Show Gist options
  • Save udonchan/404987 to your computer and use it in GitHub Desktop.
Save udonchan/404987 to your computer and use it in GitHub Desktop.
#!/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