{"id":333,"date":"2007-07-09T08:04:16","date_gmt":"2007-07-08T23:04:16","guid":{"rendered":"https:\/\/wp-78qb7hnp.pistolfly.jp\/weblog\/2007\/07\/post-41.html"},"modified":"2012-07-08T23:38:41","modified_gmt":"2012-07-08T14:38:41","slug":"post-41","status":"publish","type":"post","link":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html","title":{"rendered":"===\u6f14\u7b97\u5b50"},"content":{"rendered":"<p><a title=\"Part2\u3000Ruby\u306b\u5b66\u3076\u300cRuby on Rails\u306e\u6b63\u4f53\u300d\uff1aITpro\" href=\"http:\/\/itpro.nikkeibp.co.jp\/article\/COLUMN\/20070626\/275943\/?ST=develop&P=2\">Part2\u3000Ruby\u306b\u5b66\u3076\u300cRuby on Rails\u306e\u6b63\u4f53\u300d\uff1aITpro<\/a><\/p>\n<pre class=\"prettyprint\">def normalize_input(user_input)\r\n return case user_input\r\n when Numeric\r\n  user_input # \u6570\u5024\u306f\u305d\u306e\u307e\u307e\r\n when 'inf'\r\n  1.0 \/ 0.0 # inf\u306f\u7121\u9650\u5927\r\n when 'a' .. 'f'\r\n  user_input.hex # a\u304b\u3089f\u307e\u3067\u306e\u6587\u5b57\u309216\u9032\u6570\u3068\u89e3\u91c8\r\n when \/^[0-9]+$\/\r\n  user_input.to_i # \u6570\u5b57\u304b\u3089\u306a\u308b\u6587\u5b57\u5217\u3092\u6570\u5024\u5316\r\n else\r\n  raise # \u305d\u308c\u4ee5\u5916\u306f\u30a8\u30e9\u30fc\r\n end\r\nend<\/pre>\n<pre class=\"prettyprint\">def normalize_input(user_input)\r\n return if user_input.kind_of? Numeric then\r\n  user_input\r\n elsif 'inf' == user_input then\r\n  1.0 \/ 0.0\r\n elsif ('a' .. 'f').include? user_input then\r\n  user_input.hex\r\n elsif \/^[0-9]+$\/.match? user_input then\r\n  user_input.to_i\r\n else\r\n  raise\r\n end\r\nend<\/pre>\n<blockquote cite=\"http:\/\/itpro.nikkeibp.co.jp\/article\/COLUMN\/20070626\/275943\/?ST=develop&P=2\"><p>\nObject#===\u30e1\u30bd\u30c3\u30c9\u306f\uff0c\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u540c\u5024\u6f14\u7b97\u5b50==\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u305f\u3081\uff0c2\u756a\u76ee\u306e\u6761\u4ef6\u5224\u5b9a\u306f\uff0c'inf' == user_input\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<br \/>\n\u4e00\u65b9\uff0cClass\u30af\u30e9\u30b9\u3067\u306f===\u30e1\u30bd\u30c3\u30c9\u306f\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3055\u308c\uff0c\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u8abf\u3079\u308b kind_of?\u30e1\u30bd\u30c3\u30c9\u3068\u540c\u69d8\u306e\u6a5f\u80fd\u3092\u6301\u3064\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\uff08\u56f32\uff09\u3002\u3053\u308c\u306b\u3088\u308a\uff0c\u6700\u521d\u306e\u300c\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3042\u308b\u304b\u3069\u3046\u304b\u300d\u3068\u3044\u3046\u6761\u4ef6\u5224\u5b9a\u304c\u3046\u307e\u304f\u3044\u304f\u306e\u3067\u3059\u3002<br \/>\n\u540c\u69d8\u306b\uff0cRange(\u7bc4\u56f2)\u30af\u30e9\u30b9\u3067\u306f\uff0c\u7bc4\u56f2\u5185\u3067\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3059\u308binclude?\u30e1\u30bd\u30c3\u30c9\u3067\u3042\u308b\u304b\u306e\u3088\u3046\u306b\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3055\u308c\uff0cRegex(\u6b63\u898f\u8868\u73fe)\u30af\u30e9\u30b9\u3067\u306f\uff0c\u30de\u30c3\u30c1\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3059\u308bmatch?\u3067\u3042\u308b\u304b\u306e\u3088\u3046\u306b\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\nRuby\u306e\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\uff0c\u30af\u30e9\u30b9\u3054\u3068\u306b\u9069\u5207\u306a\u5b9f\u88c5\u3067Object#===\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b\u3053\u3068\u3067\uff0ccase\u5f0f\u306e\u67d4\u8edf\u306a\u6319\u52d5\u3092\u5b9f\u73fe\u3057\u3066\u3044\u307e\u3059\u3002\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Part2\u3000Ruby\u306b\u5b66\u3076\u300cRuby on Rails\u306e\u6b63\u4f53\u300d\uff1aITpro def normalize_input(user_input) return case user_input when Numeric user &hellip; <a href=\"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">===\u6f14\u7b97\u5b50<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[27],"tags":[],"class_list":["post-333","post","type-post","status-publish","format-standard","hentry","category-ruby","ja"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>===\u6f14\u7b97\u5b50 - Pistolfly<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"===\u6f14\u7b97\u5b50 - Pistolfly\" \/>\n<meta property=\"og:description\" content=\"Part2\u3000Ruby\u306b\u5b66\u3076\u300cRuby on Rails\u306e\u6b63\u4f53\u300d\uff1aITpro def normalize_input(user_input) return case user_input when Numeric user &hellip; \u7d9a\u304d\u3092\u8aad\u3080 ===\u6f14\u7b97\u5b50 &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html\" \/>\n<meta property=\"og:site_name\" content=\"Pistolfly\" \/>\n<meta property=\"article:published_time\" content=\"2007-07-08T23:04:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-07-08T14:38:41+00:00\" \/>\n<meta name=\"author\" content=\"Pistolfly\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pistolfly\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/2007\\\/07\\\/post-41.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/2007\\\/07\\\/post-41.html\"},\"author\":{\"name\":\"Pistolfly\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#\\\/schema\\\/person\\\/e779e918730b507907b3a35b77a9a2ab\"},\"headline\":\"===\u6f14\u7b97\u5b50\",\"datePublished\":\"2007-07-08T23:04:16+00:00\",\"dateModified\":\"2012-07-08T14:38:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/2007\\\/07\\\/post-41.html\"},\"wordCount\":20,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#\\\/schema\\\/person\\\/e779e918730b507907b3a35b77a9a2ab\"},\"articleSection\":[\"Ruby\"],\"inLanguage\":\"ja\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/2007\\\/07\\\/post-41.html\",\"url\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/2007\\\/07\\\/post-41.html\",\"name\":\"===\u6f14\u7b97\u5b50 - Pistolfly\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#website\"},\"datePublished\":\"2007-07-08T23:04:16+00:00\",\"dateModified\":\"2012-07-08T14:38:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/2007\\\/07\\\/post-41.html#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/2007\\\/07\\\/post-41.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/2007\\\/07\\\/post-41.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u30db\u30fc\u30e0\",\"item\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"===\u6f14\u7b97\u5b50\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#website\",\"url\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/\",\"name\":\"Pistolfly\",\"description\":\"Developer Blog\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#\\\/schema\\\/person\\\/e779e918730b507907b3a35b77a9a2ab\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ja\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/#\\\/schema\\\/person\\\/e779e918730b507907b3a35b77a9a2ab\",\"name\":\"Pistolfly\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g\",\"caption\":\"Pistolfly\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g\"},\"description\":\"Software Engineer in Tokyo, Japan\",\"url\":\"https:\\\/\\\/www.pistolfly.com\\\/weblog\\\/author\\\/pistolfly\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"===\u6f14\u7b97\u5b50 - Pistolfly","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html","og_locale":"ja_JP","og_type":"article","og_title":"===\u6f14\u7b97\u5b50 - Pistolfly","og_description":"Part2\u3000Ruby\u306b\u5b66\u3076\u300cRuby on Rails\u306e\u6b63\u4f53\u300d\uff1aITpro def normalize_input(user_input) return case user_input when Numeric user &hellip; \u7d9a\u304d\u3092\u8aad\u3080 ===\u6f14\u7b97\u5b50 &rarr;","og_url":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html","og_site_name":"Pistolfly","article_published_time":"2007-07-08T23:04:16+00:00","article_modified_time":"2012-07-08T14:38:41+00:00","author":"Pistolfly","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"Pistolfly"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html#article","isPartOf":{"@id":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html"},"author":{"name":"Pistolfly","@id":"https:\/\/www.pistolfly.com\/weblog\/#\/schema\/person\/e779e918730b507907b3a35b77a9a2ab"},"headline":"===\u6f14\u7b97\u5b50","datePublished":"2007-07-08T23:04:16+00:00","dateModified":"2012-07-08T14:38:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html"},"wordCount":20,"publisher":{"@id":"https:\/\/www.pistolfly.com\/weblog\/#\/schema\/person\/e779e918730b507907b3a35b77a9a2ab"},"articleSection":["Ruby"],"inLanguage":"ja"},{"@type":"WebPage","@id":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html","url":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html","name":"===\u6f14\u7b97\u5b50 - Pistolfly","isPartOf":{"@id":"https:\/\/www.pistolfly.com\/weblog\/#website"},"datePublished":"2007-07-08T23:04:16+00:00","dateModified":"2012-07-08T14:38:41+00:00","breadcrumb":{"@id":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pistolfly.com\/weblog\/2007\/07\/post-41.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u30db\u30fc\u30e0","item":"https:\/\/www.pistolfly.com\/weblog"},{"@type":"ListItem","position":2,"name":"===\u6f14\u7b97\u5b50"}]},{"@type":"WebSite","@id":"https:\/\/www.pistolfly.com\/weblog\/#website","url":"https:\/\/www.pistolfly.com\/weblog\/","name":"Pistolfly","description":"Developer Blog","publisher":{"@id":"https:\/\/www.pistolfly.com\/weblog\/#\/schema\/person\/e779e918730b507907b3a35b77a9a2ab"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pistolfly.com\/weblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ja"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pistolfly.com\/weblog\/#\/schema\/person\/e779e918730b507907b3a35b77a9a2ab","name":"Pistolfly","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/secure.gravatar.com\/avatar\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g","caption":"Pistolfly"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/0b3ddb2859adabf28a2b97ae9fff98772ddffc46088d11cad2b9a2cef66115e7?s=96&d=mm&r=g"},"description":"Software Engineer in Tokyo, Japan","url":"https:\/\/www.pistolfly.com\/weblog\/author\/pistolfly"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paorzz-5n","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/posts\/333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/comments?post=333"}],"version-history":[{"count":1,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/posts\/333\/revisions"}],"predecessor-version":[{"id":1458,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/posts\/333\/revisions\/1458"}],"wp:attachment":[{"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/media?parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/categories?post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pistolfly.com\/weblog\/wp-json\/wp\/v2\/tags?post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}