{"id":9197,"date":"2013-10-31T20:50:59","date_gmt":"2013-10-31T11:50:59","guid":{"rendered":"http:\/\/twitter-395880579113025536-post"},"modified":"2017-06-13T03:12:06","modified_gmt":"2017-06-12T18:12:06","slug":"okayama-rb22","status":"publish","type":"post","link":"https:\/\/arison.jp\/blog\/2013\/10\/31\/okayama-rb22\/","title":{"rendered":"Okayama.rb #22 \u53c2\u52a0\u3057\u3066\u307f\u305f"},"content":{"rendered":"<p>\u4eca\u65e5\u306f\u3053\u306e\u30a4\u30d9\u30f3\u30c8\u306b\u53c2\u52a0\u3057\u3066\u307e\u3059\u3002<\/p>\n<p>Okayama.rb #22 &#8211; Okayama.rb<br \/>\nhttp:\/\/www.circleaf.com\/events\/49<\/p>\n<p>\u96c6\u307e\u3063\u3066Ruby\u306b\u95a2\u3059\u308b\u4f55\u304b\u3092\u3057\u307e\u3057\u3087\u3046<br \/>\n2013\u5e7410\u670831\u65e5(\u6728) 19:00 \u301c 21:30<\/p>\n<p>\u4eca\u65e5\u306e\u8a71\u984c\u306f\u3001\u50d5\u306e\u4e2d\u3067\u306f\u3001\u4e2d\uff12\u30ce\u30fc\u30c8\u3068\u7a7a\u60f3\u90fd\u5e02\u306e\u4e2d\u6751\u5e02\u306e\u4ef6\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u7a7a\u60f3\u90fd\u5e02\u3078\u884c\u3053\u3046\uff01 \uff0f \u5730\u7406\u4eba\u304c\u3001\u7a7a\u60f3\u90fd\u5e02\u3092\u8a73\u7d30\u5730\u56f3\u3067\u63cf\u304f\u3002<br \/>\n<a href=\"http:\/\/imgcity.chirijin.com\/\" title=\"\u7a7a\u60f3\u90fd\u5e02\u3078\u884c\u3053\u3046\uff01\">http:\/\/imgcity.chirijin.com\/<\/a><\/p>\n<p>\u5730\u56f3\u3060\u3051\u3067\u306a\u304f\u3001\u4f01\u696d\u30ed\u30b4\u307e\u3067\u3002\u305d\u3057\u3066\u3001\u5730\u56f3\u306b\u306f\u4e0a\u66f8\u304d\u3055\u308c\u7d9a\u3051\u308b\u6b74\u53f2\u304c\u3042\u308b\u3002<br \/>\n\u5834\u6240\u3060\u3051\u3067\u306a\u304f\u3001\u6b74\u53f2\u304c\u3042\u308a\u3001\u5fc3\u304c\u3042\u308b\u3002\u305d\u308c\u304c\u4e2d\u6751\u5e02\u3002<\/p>\n<p>\u7ba1\u7406\u4eba\u306f\u3053\u3093\u306a\u4eba\u3002<\/p>\n<blockquote><p>\u5730\u7406\u4eba (\u4eca\u548c\u6cc9 \u9686\u884c)<br \/>\n1985\u5e74\u9e7f\u5150\u5cf6\u5e02\u751f\u307e\u308c\u3002\u751f\u5f8c\u3059\u3050\u306b\u6a2a\u6d5c\u5e02\u306b\u79fb\u308b\u3002\u30d0\u30b9\u304b\u3089\u306e\u8eca\u7a93\u89b3\u5bdf\u304c\u597d\u304d\u3067\u3001\u3088\u304f1\u4e07\u5206\u306e1\u9053\u8def\u5730\u56f3\u3084\u30d0\u30b9\u306e\u8def\u7dda\u56f3\u3092\u898b\u3066\u3044\u305f\u3002\u898b\u3066\u3044\u308b\u3060\u3051\u3067\u306f\u6e08\u307e\u306a\u304f\u306a\u308a\u30017\u6b73\u306e\u3068\u304d\u306b\u81ea\u5206\u3067\u9053\u8def\u5730\u56f3\u3084\u30d0\u30b9\u306e\u8def\u7dda\u56f3\u3092\u63cf\u304d\u59cb\u3081\u305f\u3002\u4e2d\u5b66\u6821\u306b\u306a\u3063\u3066\u3082\u3001\u9ad8\u6821\u306b\u306a\u3063\u3066\u3082\u63cf\u304d\u7d9a\u3051\u3001\u305d\u308c\u306f\u3084\u304c\u3066\u201d\u73fe\u5b9f\u7684\u306a\u201d\u73fe\u5b9f\u9003\u907f\u306e\u821e\u53f0\u3068\u306a\u3063\u3066\u304f\u308b\u3002\u5927\u5b662\u5e74\u3067\u4e00\u65e6\u4e2d\u65ad\u3057\u305f\u304c\u300125\u6b73\u306b\u306a\u3063\u3066\u304b\u3089\u5730\u56f3\u4f5c\u308a\u3092\u518d\u958b\u300220\u6b73\u524d\u5f8c\u306e\u79c1\u304c\u63cf\u304d\u304d\u308c\u306a\u304b\u3063\u305f\u30ea\u30a2\u30ea\u30c6\u30a3\u3092\u518d\u5ea6\u8ffd\u6c42\u3057\u3066\u3044\u308b\u3002<\/p><\/blockquote>\n<p>\u7ba1\u7406\u4eba\u306e\u4e2d\u6751\u5e02\u306e\u304a\u30b9\u30b9\u30e1\u30b9\u30dd\u30c3\u30c8\u306b\u5bfe\u3059\u308b\u56de\u7b54\u304c\u7d20\u6674\u3089\u3057\u3044\u3002<br \/>\n\u305c\u3072\u3001\u30ea\u30f3\u30af\u5148\u304b\u3089\u8eab\u306b\u884c\u3063\u3066\u307b\u3057\u3044\u3002<br \/>\n\u30af\u30ea\u30a8\u30a4\u30c6\u30a3\u30d6\u9b42\u306e\u584a\u3068\u3044\u3063\u305f\u611f\u3058\u3060\u3002<\/p>\n<hr \/>\n<p>\u8a2d\u697d\u9678 WEB\u3000\u300e\u73fe\u4ee3\u30a2\u30fc\u30c8\u30fb\u67b6\u7a7a\u306e\u6b74\u53f2\u30ce\u30fc\u30c8\u30fb\u67b6\u7a7a\u306e\u6f2b\u753b\u30ce\u30fc\u30c8\u300f<br \/>\n<a href=\"http:\/\/wwwbakudanrobocom.blogspot.jp\/\" title=\"\u8a2d\u697d\u9678 WEB\u3000\u300e\u73fe\u4ee3\u30a2\u30fc\u30c8\u30fb\u67b6\u7a7a\u306e\u6b74\u53f2\u30ce\u30fc\u30c8\u30fb\u67b6\u7a7a\u306e\u6f2b\u753b\u30ce\u30fc\u30c8\u300f\">http:\/\/wwwbakudanrobocom.blogspot.jp\/<\/a><\/p>\n<p>\u30a2\u30de\u30be\u30f3\u3067\u4e2d\u4e8c\u75c5\u5168\u958b\u306a\u843d\u66f8\u304d\u30ce\u30fc\u30c8\u300c\u67b6\u7a7a\u306e\u6b74\u53f2\u30ce\u30fc\u30c8-\uff11 \u5e1d\u56fd\u53f2 \u5206\u88c2\u5927\u6226\u7de8\u300d<\/p>\n<hr \/>\n<p>Ruby\u306emethod_missing\u30e1\u30bd\u30c3\u30c9\u306e\u52d5\u304d\u306b\u611f\u52d5\u3057\u305f\u3002<br \/>\n\u5b9a\u7fa9\u3057\u3066\u3044\u306a\u3044\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u305f\u3068\u304d\u306e\u52d5\u4f5c\u3092\u8a18\u8ff0\u3067\u304d\u308b\u3068\u3044\u3046\u70b9\u3002<br \/>\n\u305d\u308c\u3092\u5229\u7528\u3057\u3066\u3001\u5b9a\u7fa9\u3057\u3066\u3044\u306a\u3044\u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u305f\u3068\u304d\u306b<br \/>\n\u30e1\u30bd\u30c3\u30c9\u540d\u306e\u30eb\u30fc\u30eb\u306b\u5f93\u3063\u3066\u9069\u5207\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u5b9f\u884c\u7d50\u679c\u3092\u8fd4\u3059\u3002<\/p>\n<p>Java\u306e\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u3048\u3070\u3001Ruby\u306emethod_missing\u30e1\u30bd\u30c3\u30c9\u306a\u3053\u3068\u3067\u304d\u308b\u304b\u306a\u3068\u3002<\/p>\n<p>\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u53c2\u8003\u30b5\u30a4\u30c8<\/p>\n<p>Java\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u30e1\u30e2(Hishidama&#8217;s Java Reflection Memo)<br \/>\n<a href=\"http:\/\/www.ne.jp\/asahi\/hishidama\/home\/tech\/java\/reflection.html\" title=\"Java\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u30e1\u30e2(Hishidama's Java Reflection Memo)\">http:\/\/www.ne.jp\/asahi\/hishidama\/home\/tech\/java\/reflection.html<\/a><\/p>\n<p>\u81ea\u5206\u306e\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308c\u3070\u305d\u308c\u3092\u547c\u3073\u51fa\u3057\u3066\u5b9f\u884c\u7d50\u679c\u3092\u8fd4\u3059\u3002<br \/>\n\u81ea\u5206\u306e\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u306a\u3051\u308c\u3070\u3001\u30e1\u30bd\u30c3\u30c9\u540d\u306e\u30eb\u30fc\u30eb\u306b\u5f93\u3063\u3066\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u5b9f\u884c\u7d50\u679c\u3092\u8fd4\u3059\u3002<\/p>\n<p>\u3082\u3063\u3068\u307e\u3058\u3081\u306b\u4f5c\u308c\u3070\u9762\u767d\u3044\u3082\u306e\u304c\u4f5c\u308c\u305d\u3046\u306a\u6c17\u304c\u3059\u308b\u3002<\/p>\n<p>MissingMethod.java<br \/>\n[java]<br \/>\nimport java.lang.reflect.InvocationTargetException;<br \/>\nimport java.lang.reflect.Method;<\/p>\n<p>public class MissingMethod {<\/p>\n<p>    \/**<br \/>\n     * \u30c6\u30b9\u30c8\u7528<br \/>\n     *<br \/>\n     * @param args<br \/>\n     *\/<br \/>\n    public static void main(String[] args) {<br \/>\n        MissingMethod mm = new MissingMethod();<br \/>\n        System.out.println(mm.execute(&amp;quot;one&amp;quot;));<br \/>\n        System.out.println(mm.execute(&amp;quot;test1&amp;quot;));<br \/>\n        System.out.println(mm.execute(&amp;quot;test2&amp;quot;));<br \/>\n        System.out.println(mm.execute(&amp;quot;hoge&amp;quot;));<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u5b58\u5728\u3057\u306a\u3044\u30e1\u30bd\u30c3\u30c9\u306e\u5834\u5408\u306f\u9069\u5f53\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u6210\u3057\u3066\u304f\u308c\u308b<br \/>\n     *<br \/>\n     * @param methodName \u30e1\u30bd\u30c3\u30c9\u540d<br \/>\n     * @return \u623b\u308a\u5024<br \/>\n     * @throws InvocationTargetException<br \/>\n     * @throws IllegalAccessException<br \/>\n     * @throws IllegalArgumentException<br \/>\n     *\/<br \/>\n    public Object execute(String methodName) {<br \/>\n        Object obj = null;<\/p>\n<p>        Method method;<br \/>\n        try {<br \/>\n            method = this.getClass().getMethod(methodName, null);<br \/>\n            obj = method.invoke(this, null);<br \/>\n        } catch (SecurityException e1) {<br \/>\n            return &amp;quot;SecurityException:&amp;quot; + methodName;<br \/>\n        } catch (NoSuchMethodException e1) {<br \/>\n            MethodCreate mc = new MethodCreate();<br \/>\n            obj = mc.execute(methodName);<br \/>\n        } catch (IllegalArgumentException e) {<br \/>\n            return &amp;quot;IllegalArgumentException:&amp;quot; + methodName;<br \/>\n        } catch (IllegalAccessException e) {<br \/>\n            return &amp;quot;IllegalAccessException:&amp;quot; + methodName;<br \/>\n        } catch (InvocationTargetException e) {<br \/>\n            return &amp;quot;InvocationTargetException:&amp;quot; + methodName;<br \/>\n        }<br \/>\n        return obj;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * &amp;quot;one&amp;quot;\u51fa\u529b<br \/>\n     *<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    public Object one() {<br \/>\n        return &amp;quot;one&amp;quot;;<br \/>\n    }<\/p>\n<p>}<br \/>\n[\/java]<\/p>\n<p>MethodCreatable.java<br \/>\n[java]<br \/>\n\/**<br \/>\n * \u81ea\u52d5\u30e1\u30bd\u30c3\u30c9\u4f5c\u6210\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9<br \/>\n * @author arimura<br \/>\n *<br \/>\n *\/<br \/>\npublic interface MethodCreatable {<br \/>\n    public Object execute(String methodName);<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>MethodCreate.java<br \/>\n[java]<br \/>\nimport java.lang.reflect.InvocationTargetException;<br \/>\nimport java.lang.reflect.Method;<\/p>\n<p>\/**<br \/>\n * \u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u6210\u3059\u308b\u30af\u30e9\u30b9<br \/>\n * MethodCreatable\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3059\u308b\u3002<br \/>\n *\/<br \/>\npublic class MethodCreate implements MethodCreatable {<\/p>\n<p>    \/**<br \/>\n     * \u5b9f\u884c\u30af\u30e9\u30b9<br \/>\n     *\/<br \/>\n    @Override<br \/>\n    public Object execute(String methodName) {<br \/>\n        Object obj = null;<br \/>\n        try {<br \/>\n            Method method = this.getClass().getMethod(methodName, null);<br \/>\n            return method.invoke(this, null);<br \/>\n        } catch (SecurityException e) {<br \/>\n            return null;<br \/>\n        } catch (NoSuchMethodException e) {<br \/>\n            return &amp;quot;NoSuchMethodException:&amp;quot; + methodName;<br \/>\n        } catch (IllegalArgumentException e) {<br \/>\n            return &amp;quot;IllegalArgumentException:&amp;quot; + methodName;<br \/>\n        } catch (IllegalAccessException e) {<br \/>\n            return &amp;quot;IllegalAccessException:&amp;quot; + methodName;<br \/>\n        } catch (InvocationTargetException e) {<br \/>\n            return &amp;quot;InvocationTargetException:&amp;quot; + methodName;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * MethodCreate\u30e1\u30bd\u30c3\u30c91<br \/>\n     *<br \/>\n     * @return test1\u3092\u8fd4\u3059<br \/>\n     *\/<br \/>\n    public Object test1() {<br \/>\n        Object obj = null;<br \/>\n        obj = &amp;quot;test1&amp;quot;;<br \/>\n        return obj;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * MethodCreate\u30e1\u30bd\u30c3\u30c92<br \/>\n     *<br \/>\n     * @return test2\u3092\u8fd4\u3059<br \/>\n     *\/<br \/>\n    public Object test2() {<br \/>\n        Object obj = null;<br \/>\n        obj = &amp;quot;test2&amp;quot;;<br \/>\n        return obj;<br \/>\n    }<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>\u5b9f\u884c\u4f8b<\/p>\n<p>one<br \/>\ntest1<br \/>\ntest2<br \/>\nNoSuchMethodException:hoge<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u306f\u3053\u306e\u30a4\u30d9\u30f3\u30c8\u306b\u53c2\u52a0\u3057\u3066\u307e\u3059\u3002 Okayama.rb #22 &#8211; Okayama.rb http:\/\/www.circleaf.com\/events\/49 \u96c6\u307e\u3063\u3066Ruby\u306b\u95a2\u3059\u308b\u4f55\u304b\u3092\u3057\u307e\u3057\u3087\u3046 201 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":23890,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"status","meta":{"footnotes":""},"categories":[6,4],"tags":[158],"class_list":["post-9197","post","type-post","status-publish","format-status","has-post-thumbnail","hentry","category-programming","category-diary","tag-ruby","post_format-post-format-status"],"_links":{"self":[{"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/posts\/9197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/comments?post=9197"}],"version-history":[{"count":0,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/posts\/9197\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/media\/23890"}],"wp:attachment":[{"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/media?parent=9197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/categories?post=9197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arison.jp\/blog\/wp-json\/wp\/v2\/tags?post=9197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}