{"id":452,"date":"2015-07-30T19:09:03","date_gmt":"2015-07-30T10:09:03","guid":{"rendered":"http:\/\/tech.at-iroha.jp\/?p=452"},"modified":"2015-08-08T10:37:39","modified_gmt":"2015-08-08T01:37:39","slug":"ruby-%e3%81%ae%e5%9f%ba%e6%9c%ac%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%81%a8%e5%91%a8%e8%be%ba%e6%8a%80%e8%a1%93%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/tech.at-iroha.jp\/?p=452","title":{"rendered":"Ruby \u306e\u57fa\u672c\u30b3\u30de\u30f3\u30c9\u3068\u5468\u8fba\u6280\u8853\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p>\u6700\u8fd1\u3001\u521d\u3081\u3066 Ruby \u3067\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u306e\u3067\u3001Ruby \u306e\u57fa\u672c\u7684\u306a\u30b3\u30de\u30f3\u30c9\u3084\u3001\u5468\u8fba\u6280\u8853\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002Ruby \u306e\u6587\u6cd5\u306b\u3064\u3044\u3066\u306f\u3053\u3053\u3067\u306f\u89e6\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>Ruby \u3068\u306f1995\u5e74\u306b\u65e5\u672c\u3067\u958b\u767a\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5fd7\u5411\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u3067\u3059\u3002\u56fd\u5185\u306e\u30b9\u30bf\u30fc\u30c8\u30a2\u30c3\u30d7\u306e\u4f01\u696d\u306e\u7d041\/4\u304c\u81ea\u793e\u30b5\u30fc\u30d3\u30b9\u306e\u958b\u767a\u306b Ruby \u3092\u63a1\u7528\u3057\u3066\u3044\u308b\u3068\u8a00\u308f\u308c\u3066\u304a\u308a\u3001PHP\u3068\u4e26\u3093\u3067\u4eba\u6c17\u306e\u8a00\u8a9e\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u307e\u305f Ruby \u306b\u306f\u9ad8\u5ea6\u306a\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0\u304c\u5f62\u6210\u3055\u308c\u3066\u304a\u308a\u3001\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u958b\u767a\u3084\u30c1\u30fc\u30e0\u306b\u3088\u308b\u958b\u767a\u306b\u3082\u5411\u3044\u3066\u3044\u308b\u8a00\u8a9e\u3068\u8a00\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Ruby \u306b\u306f\u6a19\u6e96\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30de\u30f3\u30c9\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>rbenv<\/h2>\n<p>Ruby \u306e\u74b0\u5883\u8a2d\u5b9a\u3092\u884c\u3046\u30b3\u30de\u30f3\u30c9\u3067\u3059\u3002<\/p>\n<p>Ruby \u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nrbenv --version\r\n<\/pre>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308bRuby \u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u4e00\u89a7\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nrbenv versions\r\n<\/pre>\n<p>Ruby \u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nrbenv global 2.2.2\r\n<\/pre>\n<h2>irb<\/h2>\n<p>Ruby \u306e\u30b3\u30fc\u30c9\u3092\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u3067\u5b9f\u884c\u3059\u308b\u30c4\u30fc\u30eb\u3067\u3059\u3002irb \u3068\u3044\u3046\u540d\u524d\u306f\u00a0Interactive Ruby \u306b\u7531\u6765\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>irb \u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nirb\r\n<\/pre>\n<p>Ruby \u306e\u30b3\u30fc\u30c9\u30921\u884c\u30011\u884c\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b\u5b9f\u884c\u4f8b<br \/>\n<a href=\"http:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/irb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-469\" src=\"http:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/irb.png\" alt=\"irb\" width=\"677\" height=\"392\" srcset=\"https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/irb.png 677w, https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/irb-600x347.png 600w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/a><\/p>\n<h2>ruby<\/h2>\n<p>ruby \u3068\u306f Ruby \u3067\u66f8\u304b\u308c\u305f\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nruby helloworld.rb\r\n<\/pre>\n<p>helloworld.rb<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\nprint(&quot;Hello World&quot;)\r\n<\/pre>\n<h2>gem<\/h2>\n<p>gem \u3068\u306f Ruby \u3067\u66f8\u304b\u308c\u305f\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u3053\u3068\u3092\u6307\u3057\u3066\u304a\u308a\u3001gem \u3092\u7ba1\u7406\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3082 gem \u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u82f1\u8a9e\u3067\u5b9d\u77f3\u3092\u610f\u5473\u3059\u308b gem\u00a0\u306b\u7531\u6765\u3057\u3066\u3044\u307e\u3059\u3002gemname.gemspec (gemname \u306e\u90e8\u5206\u306f\u5b9f\u969b\u306b\u306f gem \u306e\u540d\u524d\u306b\u7f6e\u304d\u63db\u308f\u308a\u307e\u3059\u3002)\u306b gem \u306b\u95a2\u3059\u308b\u8aac\u660e\u3084\u3001gem \u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p>gem \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngem install gemname\r\n<\/pre>\n<p>gem \u306e\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngem uninstall gemname\r\n<\/pre>\n<p>\u30ed\u30fc\u30ab\u30eb\u306e gem \u3092\u30d3\u30eb\u30c9\u3057\u307e\u3059<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngem build gemname.gemspec\r\n<\/pre>\n<p>\u30d3\u30eb\u30c9\u3057\u305f gem \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngem install .\/gemname-0.1.0.gem\r\n<\/pre>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u306e gem \u30ea\u30b9\u30c8\u8868\u793a<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngem list --local\r\n<\/pre>\n<p>gemname.gemspec \u306e\u5185\u5bb9<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\n# coding: utf-8\r\nlib = File.expand_path('..\/lib', __FILE__)\r\n$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)\r\nrequire 'my_gem_miura\/version'\r\n\r\nGem::Specification.new do |spec|\r\n  spec.name          = &quot;my_gem_miura&quot;\r\n  spec.version       = MyGemMiura::VERSION\r\n  spec.authors       = &#x5B;&quot;Kotaro Miura&quot;]\r\n  spec.email         = &#x5B;&quot;miura@at-iroha.jp&quot;]\r\n\r\n  spec.summary       = %q{Clac your age}\r\n  spec.description   = %q{This is an AIIT student's test program in Japan.}\r\n  spec.homepage      = &quot;http:\/\/aiit.ac.jp&quot;\r\n  spec.license       = &quot;MIT&quot;\r\n\r\n  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or\r\n  # delete this section to allow pushing this gem to any host.\r\n  if spec.respond_to?(:metadata)\r\n    spec.metadata&#x5B;'allowed_push_host'] = &quot;http:\/\/mygemserver.com&quot;\r\n  else\r\n    raise &quot;RubyGems 2.0 or newer is required to protect against public gem pushes.&quot;\r\n  end\r\n\r\n  spec.files         = `git ls-files -z`.split(&quot;\\x0&quot;).reject { |f| f.match(%r{^(test|spec|features)\/}) }\r\n  spec.bindir        = &quot;exe&quot;\r\n  spec.executables   = spec.files.grep(%r{^exe\/}) { |f| File.basename(f) }\r\n  spec.require_paths = &#x5B;&quot;lib&quot;]\r\n\r\n  spec.add_development_dependency &quot;bundler&quot;, &quot;~&gt; 1.10&quot;\r\n  spec.add_development_dependency &quot;rake&quot;, &quot;~&gt; 10.0&quot;\r\n  spec.add_development_dependency &quot;rspec&quot;\r\nend\r\n<\/pre>\n<h3>RubyGems<\/h3>\n<p>RubyGems \u3068\u306f Ruby \u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u3067\u3059\u3002RubyGems \u306b\u306f\u8ab0\u3082\u304c\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u767b\u9332\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u767b\u9332\u3055\u308c\u305f\u30e9\u30a4\u30d6\u30e9\u30ea\u306f gem \u30b3\u30de\u30f3\u30c9\u306b\u3066\u7c21\u5358\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/rubygems.org\/\" target=\"_blank\">https:\/\/rubygems.org\/<\/a><\/p>\n<p><a href=\"http:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/rubygems.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/rubygems-1024x704.png\" alt=\"rubygems\" width=\"640\" height=\"440\" class=\"alignnone size-large wp-image-515\" srcset=\"https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/rubygems-1024x704.png 1024w, https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/rubygems-600x413.png 600w, https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/rubygems.png 1166w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<h3>Rake<\/h3>\n<p>Rake \u3068\u306f Make \u306b\u3088\u304f\u4f3c\u305f\u6a5f\u80fd\u3092\u6301\u3064 Ruby \u3067\u66f8\u304b\u308c\u305f\u30b7\u30f3\u30d7\u30eb\u306a\u30d3\u30eb\u30c9\u30c4\u30fc\u30eb\u3067\u3059\u3002Rakefile \u3092\u5143\u306b\u30d3\u30eb\u30c9\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>rake \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngem install rake\r\n<\/pre>\n<p>Rakefile \u306e\u8a18\u8ff0\u4f8b<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\nrequire &quot;bundler\/gem_tasks&quot;\r\nrequire &quot;rake\/testtask&quot;\r\n\r\nRake::TestTask.new(:test) do |t|\r\n  t.libs &lt;&lt; &quot;test&quot;\r\n  t.libs &lt;&lt; &quot;lib&quot;\r\n  t.test_files = FileList&#x5B;'test\/**\/*_test.rb']\r\nend\r\n\r\ntask :default =&gt; :test\r\n<\/pre>\n<p>\u30d1\u30bf\u30fc\u30f3\u306b\u30de\u30c3\u30c1\u3057\u305f\u30bf\u30b9\u30af\u306e\u77ed\u3044\u8aac\u660e\u3092\u8868\u793a\u3057\u307e\u3059<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nrake -T\r\n<\/pre>\n<p>\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u307e\u3059<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nrake test\r\n<\/pre>\n<p>\u30d3\u30eb\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nrake build\r\n<\/pre>\n<h2>Bundler<\/h2>\n<p>Bundler \u3068\u306f\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4f9d\u5b58\u95a2\u4fc2\u306e\u7ba1\u7406\u3059\u308b\u6280\u8853\u3067\u3059\u3002gem \u306f\u66f4\u65b0\u983b\u5ea6\u304c\u9ad8\u304f\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u3088\u3063\u3066\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u6b63\u5e38\u306b\u52d5\u4f5c\u3057\u306a\u304f\u306a\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u306e\u304c Bundler \u3068\u306a\u308a\u307e\u3059\u3002Bundler \u306f GemFile \u306e\u8a18\u8ff0\u3092\u5143\u306b\u5404\u7a2e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u81ea\u52d5\u7684\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002bundle \u30b3\u30de\u30f3\u30c9\u306b\u3066\u5404\u7a2e\u64cd\u4f5c\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>Bundler \u306e\u4f7f\u3044\u65b9<\/p>\n<p>Gemfile \u306e\u3072\u306a\u5f62\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nbundle init\r\n<\/pre>\n<p>Gemfile \u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\nsource 'https:\/\/rubygems.org'\r\ngem 'nokogiri'\r\ngem 'rspec'\r\n<\/pre>\n<p>Gemfile \u306e\u8a18\u8ff0\u3092\u5143\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nbundle install\r\n<\/pre>\n<p>#bundle \u30b3\u30de\u30f3\u30c9\u3067 gem \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nbundle gem gemname\r\n<\/pre>\n<h2>Minitest<\/h2>\n<p>Minittest \u3068\u306f Ruby \u306b\u6a19\u6e96\u3067\u642d\u8f09\u3055\u308c\u3066\u3044\u308b\u5358\u4f53\u30c6\u30b9\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\u6700\u8fd1\u3067\u306f Minitest \u3088\u308a\u3082\u3055\u3089\u306b\u9ad8\u6a5f\u80fd\u306a RSpec \u3082\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306e\u4f5c\u6210\u4f8b<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\nrequire 'test_helper'\r\nrequire 'gem_minitest'\r\n\r\nclass GemMinitestTest &lt; Minitest::Test\r\n\tdef setup\r\n\t\t@my = GemMiniTest.new\r\n\tend\r\n\r\n\t#odd\u30e1\u30bd\u30c3\u30c9\u30c6\u30b9\u30c8\r\n\t#\u6574\u6570\u3092\u5165\u529b\u3068\u3057\u3066\u53d7\u3051\u53d6\u308a\uff0c\u5024\u304c\u5947\u6570\u306a\u3089\u3070\u771f\u3092\u8fd4\u3059\r\n\tdef test_odd\r\n\t\tassert_equal(false, @my.odd(0))\r\n\t\tassert_equal(true,  @my.odd(1))\r\n\t\tassert_equal(false, @my.odd(2))\r\n\tend\r\n\r\n\t#check_number\u30e1\u30bd\u30c3\u30c9\u30c6\u30b9\u30c8\r\n\tdef test_check_number\r\n\t\tassert_equal(false, @my.check_number(0))\r\n\t\tassert_equal(false, @my.check_number(123))\r\n\t\tassert_equal(false, @my.check_number(1001))\r\n\t\tassert_equal(true,  @my.check_number(1000))\r\n\tend\r\n\r\n\t#enough_length\u30e1\u30bd\u30c3\u30c9\u30c6\u30b9\u30c8\r\n\tdef test_enough_length\r\n\t\t#\u5883\u754c\u5024\u30c1\u30a7\u30c3\u30af2,3,8,9\u6841\r\n\t\tassert_equal(false, @my.enough_length(&quot;12&quot;))\r\n\t\tassert_equal(true,  @my.enough_length(&quot;123&quot;))\r\n\t\tassert_equal(true,  @my.enough_length(&quot;12345678&quot;))\r\n\t\tassert_equal(false, @my.enough_length(&quot;123456789&quot;))\r\n\tend\r\n\r\n\t#divide\u30e1\u30bd\u30c3\u30c9\u30c6\u30b9\u30c8\r\n\tdef test_divide\r\n\t\tassert_equal(2, @my.divide(50, 25))\r\n\t\tassert_equal(20, @my.divide(200, 10))\r\n\tend\r\n\r\n\t#fizz_buzz\u30e1\u30bd\u30c3\u30c9\u30c6\u30b9\u30c8\r\n\tdef test_fizz_buzz\r\n\t\tassert_equal(&quot;&quot;,         @my.fizz_buzz(0))\r\n\t\tassert_equal(&quot;&quot;,         @my.fizz_buzz(1))\r\n\t\tassert_equal(&quot;Fizz&quot;,     @my.fizz_buzz(3))\r\n\t\tassert_equal(&quot;&quot;,         @my.fizz_buzz(4))\r\n\t\tassert_equal(&quot;Buzz&quot;,     @my.fizz_buzz(5))\r\n\t\tassert_equal(&quot;&quot;,         @my.fizz_buzz(14))\r\n\t\tassert_equal(&quot;FizzBuzz&quot;, @my.fizz_buzz(15))\r\n\t\tassert_equal(&quot;&quot;,         @my.fizz_buzz(16))\r\n\t\tassert_equal(&quot;&quot;,         @my.fizz_buzz(101))\r\n\tend\r\n\r\n\t#\u5f15\u6570\u306b\u6570\u5024\u30921 \u3064\u3068\u308b\uff0e3 \u306e\u500d\u6570\u306e\u6642\u306f\u201dFizz\u201d\u3092\u8fd4\u3059\uff0e5 \u306e\u500d\u6570\u306e\u6642\u306f\u201dBuzz\u201d\u3092\u8fd4\u3059\uff0e3 \u30685 \u306e\u516c\u500d\u6570\u306e\u3068\u304d\u306f\u201dFizzBuzz\u201d\u3092\u8fd4\u3059\uff0e\r\n\tdef test_hello\r\n\t\tassert_output(\/Hello\/) { @my.hello}\r\n\tend\r\nend\r\n<\/pre>\n<p>\u30c6\u30b9\u30c8\u3059\u308b\u30b3\u30fc\u30c9<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\nrequire &quot;gem_minitest\/version&quot;\r\n\r\nclass GemMiniTest\r\n\trequire 'time'\r\n\trequire 'prime'\r\n\t\r\n\t#\u6574\u6570\u3092\u5165\u529b\u3068\u3057\u3066\u53d7\u3051\u53d6\u308a\uff0c\u5024\u304c\u5947\u6570\u306a\u3089\u3070\u771f\u3092\u8fd4\u3059\r\n\tdef odd(num)\r\n\t\tif (num % 2)==1 then\r\n\t\t\treturn true\r\n\t\telse\r\n\t\t\treturn false\r\n\t\tend\r\n\tend\r\n\t\r\n\t#\u5f15\u6570\u304c0 \u4ee5\u5916\u3067\u306f\u3058\u307e\u308b4 \u6841\u306e\u6570\u5b57\u3067\u3042\u308a\uff0c\u306a\u304a\u304b\u3064\uff0c\u5024\u304c\u5076\u6570\u306a\u3089\u3070\u771f\u3092\u8fd4\u3059\r\n\tdef check_number(num)\r\n\t\t#0\u30c1\u30a7\u30c3\u30af\r\n\t\tif num==0 then\r\n\t\t\treturn false\r\n\t\tend\r\n\t\t\r\n\t\t#\u6841\u30c1\u30a7\u30c3\u30af\r\n\t\tif num.to_s.length != 4 then\r\n\t\t\treturn false\r\n\t\tend\r\n\t\t\r\n\t\t#\u5076\u6570\u30c1\u30a7\u30c3\u30af\r\n\t\tif odd(num) then\r\n\t\t\treturn false\r\n\t\telse\r\n\t\t\treturn true\r\n\t\tend\r\n\tend\r\n\t\r\n\t#\u6587\u5b57\u5217\u3092\u53d7\u3051\u53d6\u308a\uff0c\u305d\u306e\u9577\u3055\u304c3 \u6587\u5b57\u4ee5\u4e0a\uff0c8 \u6587\u5b57\u4ee5\u4e0b\u3067\u3042\u308c\u3070\u771f\u3092\u8fd4\u3059\r\n\tdef enough_length(str)\r\n\t\t#\u6700\u5c0f\u5024\u30c1\u30a7\u30c3\u30af\r\n\t\tif str.length &lt; 3 then\r\n\t\t\treturn false\r\n\t\tend\r\n\t\t\r\n\t\t#\u6700\u5927\u5024\u30c1\u30a7\u30c3\u30af\r\n\t\tif str.length &gt; 8 then\r\n\t\t\treturn false\r\n\t\tend\r\n\t\t\r\n\t\treturn true\r\n\tend\r\n\t\r\n\t#\u5f15\u6570\u3068\u3057\u3066\u5272\u308b\u6570\u3068\u5272\u3089\u308c\u308b\u6570\u3092\u53d6\u308a\uff0c\u5272\u308a\u7b97\u3092\u3057\u305f\u7d50\u679c\u3092\u8fd4\u3059\uff0e\u305f\u3060\u3057\uff0c0 \u3067\u5272\u308a\u7b97\u3092\u3057\u305f\u3089\u4f8b\u5916\u3092\u767a\u751f\u3059\u308b\r\n\tdef divide(num_n, num_d)\r\n\t\treturn (num_n \/ num_d).to_f\r\n\tend\r\n\t\r\n\t#\u5f15\u6570\u306b\u6570\u5024\u30921 \u3064\u3068\u308b\uff0e3 \u306e\u500d\u6570\u306e\u6642\u306f\u201dFizz\u201d\u3092\u8fd4\u3059\uff0e5 \u306e\u500d\u6570\u306e\u6642\u306f\u201dBuzz\u201d\u3092\u8fd4\u3059\uff0e3 \u30685 \u306e\u516c\u500d\u6570\u306e\u3068\u304d\u306f\u201dFizzBuzz\u201d\u3092\u8fd4\u3059\uff0e\r\n\tdef fizz_buzz(num)\r\n\t\tif num==0 then\r\n\t\t\treturn &quot;&quot;\r\n\t\tend\r\n\t\t\r\n\t\tif (((num % 3)==0) &amp;&amp; ((num % 5)==0)) then\r\n\t\t\treturn &quot;FizzBuzz&quot;\r\n\t\tend\r\n\t\t\r\n\t\tif (num % 3)==0 then\r\n\t\t\treturn &quot;Fizz&quot;\r\n\t\tend\r\n\t\t\r\n\t\tif (num % 5)==0 then\r\n\t\t\treturn &quot;Buzz&quot;\r\n\t\tend\r\n\t\t\r\n\t\treturn &quot;&quot;\r\n\tend\r\n\t\r\n\t#\u5f15\u6570\u306b\u6570\u5024\u30921 \u3064\u3068\u308b\uff0e3 \u306e\u500d\u6570\u306e\u6642\u306f\u201dFizz\u201d\u3092\u8fd4\u3059\uff0e5 \u306e\u500d\u6570\u306e\u6642\u306f\u201dBuzz\u201d\u3092\u8fd4\u3059\uff0e3 \u30685 \u306e\u516c\u500d\u6570\u306e\u3068\u304d\u306f\u201dFizzBuzz\u201d\u3092\u8fd4\u3059\uff0e\r\n\tdef hello()\r\n\t\tputs &quot;Hello&quot;\r\n\tend\r\nend\r\n<\/pre>\n<p>\u30c6\u30b9\u30c8\u306e\u5b9f\u884c<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nrake test\r\n<\/pre>\n<h2>Guard<\/h2>\n<p>Guard \u3068\u306f\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306a\u3069\u3092\u76e3\u8996\u3057\u3001\u30bf\u30b9\u30af\u3092\u81ea\u52d5\u7684\u306b\u5b9f\u884c\u3059\u308b\u30c4\u30fc\u30eb\u3067\u3059\u3002\u4f8b\u3048\u3070\u30a8\u30c7\u30a3\u30bf\u3067\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u5909\u66f4\u3057\u305f\u969b\u306b\u3001\u81ea\u52d5\u7684\u306b\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3055\u305b\u305f\u3044\u5834\u5408\u306a\u3069\u306b\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>Gemfile \u306b guard \u3092\u8ffd\u52a0\u3057\u307e\u3059<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\n#\u958b\u767a\u74b0\u5883\u3067\u306e\u307f guard \u3092\u8ffd\u52a0\r\ngroup :develeoment do\r\n  gem 'guard'\r\nend\r\n<\/pre>\n<p>Guardfile \u306e\u3072\u306a\u5f62\u3092\u4f5c\u6210\u3057\u307e\u3059<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nbundle exec guard init\r\n<\/pre>\n<p>\u4ee5\u4e0b\u306e\u69d8\u306a\u30d5\u30a1\u30a4\u30eb\u304c\u81ea\u52d5\u751f\u6210\u3055\u308c\u307e\u3059\u3002watch \u306e\u90e8\u5206\u306a\u3069\u3092\u74b0\u5883\u306b\u5fdc\u3058\u3066\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\nguard :minitest do\r\n# with Minitest::Unit\r\n  watch(%r{^test\/(.*)\\\/?test_(.*)\\.rb$})\r\n  watch(%r{^lib\/(.*\/)?(&#x5B;^\/]+)\\.rb$})     { |m| &quot;test\/#{m&#x5B;1]}#{m&#x5B;2]}_test.rb&quot; }\r\n  watch(%r{^test\/test_helper\\.rb$})      { 'test' }\r\n\r\n# with Minitest::Spec\r\n# watch(%r{^spec\/(.*)_spec\\.rb$})\r\n# watch(%r{^lib\/(.+)\\.rb$})         { |m| &quot;spec\/#{m&#x5B;1]}_spec.rb&quot; }\r\n# watch(%r{^spec\/spec_helper\\.rb$}) { 'spec' }\r\n\r\n# Rails 4\r\n# watch(%r{^app\/(.+)\\.rb$})                               { |m| &quot;test\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^app\/controllers\/application_controller\\.rb$}) { 'test\/controllers' }\r\n# watch(%r{^app\/controllers\/(.+)_controller\\.rb$})        { |m| &quot;test\/integration\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^app\/views\/(.+)_mailer\/.+})                   { |m| &quot;test\/mailers\/#{m&#x5B;1]}_mailer_test.rb&quot; }\r\n# watch(%r{^lib\/(.+)\\.rb$})                               { |m| &quot;test\/lib\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^test\/.+_test\\.rb$})\r\n# watch(%r{^test\/test_helper\\.rb$}) { 'test' }\r\n\r\n# Rails &lt; 4\r\n# watch(%r{^app\/controllers\/(.*)\\.rb$}) { |m| &quot;test\/functional\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^app\/helpers\/(.*)\\.rb$})     { |m| &quot;test\/helpers\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^app\/models\/(.*)\\.rb$})      { |m| &quot;test\/unit\/#{m&#x5B;1]}_test.rb&quot; }\r\n  end\r\n\r\n  guard :bundler do\r\n  require 'guard\/bundler'\r\n  require 'guard\/bundler\/verify'\r\n  helper = Guard::Bundler::Verify.new\r\n\r\n  files = &#x5B;'Gemfile']\r\n  files += Dir&#x5B;'*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }\r\n\r\n# Assume files are symlinked from somewhere\r\n  files.each { |file| watch(helper.real_path(file)) }\r\n  end\r\n\r\n  guard :minitest do\r\n# with Minitest::Unit\r\n  watch(%r{^test\/(.*)\\\/?test_(.*)\\.rb$})\r\n  watch(%r{^lib\/(.*\/)?(&#x5B;^\/]+)\\.rb$})     { |m| &quot;test\/#{m&#x5B;1]}test_#{m&#x5B;2]}.rb&quot; }\r\n  watch(%r{^test\/test_helper\\.rb$})      { 'test' }\r\n\r\n# with Minitest::Spec\r\n# watch(%r{^spec\/(.*)_spec\\.rb$})\r\n# watch(%r{^lib\/(.+)\\.rb$})         { |m| &quot;spec\/#{m&#x5B;1]}_spec.rb&quot; }\r\n# watch(%r{^spec\/spec_helper\\.rb$}) { 'spec' }\r\n\r\n# Rails 4\r\n# watch(%r{^app\/(.+)\\.rb$})                               { |m| &quot;test\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^app\/controllers\/application_controller\\.rb$}) { 'test\/controllers' }\r\n# watch(%r{^app\/controllers\/(.+)_controller\\.rb$})        { |m| &quot;test\/integration\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^app\/views\/(.+)_mailer\/.+})                   { |m| &quot;test\/mailers\/#{m&#x5B;1]}_mailer_test.rb&quot; }\r\n# watch(%r{^lib\/(.+)\\.rb$})                               { |m| &quot;test\/lib\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^test\/.+_test\\.rb$})\r\n# watch(%r{^test\/test_helper\\.rb$}) { 'test' }\r\n\r\n# Rails &lt; 4\r\n# watch(%r{^app\/controllers\/(.*)\\.rb$}) { |m| &quot;test\/functional\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^app\/helpers\/(.*)\\.rb$})     { |m| &quot;test\/helpers\/#{m&#x5B;1]}_test.rb&quot; }\r\n# watch(%r{^app\/models\/(.*)\\.rb$})      { |m| &quot;test\/unit\/#{m&#x5B;1]}_test.rb&quot; }\r\nend \r\n<\/pre>\n<p>Guard \u3092\u5b9f\u884c\u3057\u307e\u3059<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nbundle exec guard\r\n<\/pre>\n<p>\u4eee\u60f3\u74b0\u5883\u3092\u4f7f\u7528\u3057\u3066\u3044\u3066\u3001\u30db\u30b9\u30c8\u306e\u30c6\u30ad\u30b9\u30c8\u30a8\u30c7\u30a3\u30bf\u306b\u3088\u308b\u5909\u66f4\u306b\u3082\u53cd\u5fdc\u3055\u305b\u305f\u3044\u5834\u5408\u306f\u3001\u30aa\u30d7\u30b7\u30e7\u30f3 -p \u3092\u8ffd\u52a0\u3057\u307e\u3059<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nbundle exec guard -p\r\n<\/pre>\n<h2>GitHub \u3078\u306e\u30d7\u30c3\u30b7\u30e5\u65b9\u6cd5<\/h2>\n<p>Ruby \u3067\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u306f git \u30b3\u30de\u30f3\u30c9\u3067\u76f4\u63a5\u3001GitHub \u3078\u30d7\u30c3\u30b7\u30e5\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>Git\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u4f5c\u6210\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngit init\r\n<\/pre>\n<p>github\u4e0a\u306b\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\nhub create\r\n<\/pre>\n<p>Git \u3067\u7ba1\u7406\u3059\u308b\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u300c.\u300d\u306e\u5834\u5408\u3001\u5168\u3066\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u5bfe\u8c61\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngit add .\r\n<\/pre>\n<p>\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30b3\u30df\u30c3\u30c8\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngit commit -m &quot;first commit&quot;\r\n<\/pre>\n<p>\u30b3\u30df\u30c3\u30c8\u3057\u305f\u5185\u5bb9\u3092 GitHub \u4e0a\u306b\u30d7\u30c3\u30b7\u30e5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ngit push -u origin master\r\n<\/pre>\n<h2>Travis CI<\/h2>\n<p>Travis CI \u3068\u306f GitHub \u3068\u9023\u643a\u3057\u3001GitHub \u4e0a\u306e\u30bd\u30fc\u30b9\u306b\u5909\u66f4\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001Travis CI \u306b\u901a\u77e5\u3055\u308c\u3001\u5909\u66f4\u3055\u308c\u305f\u30bd\u30fc\u30b9\u3092\u81ea\u52d5\u3067\u30c6\u30b9\u30c8\u306a\u3069\u3092\u884c\u3046Web\u30b5\u30fc\u30d3\u30b9\u3067\u3059\u3002Ruby \u4ee5\u5916\u306b\u3082\u69d8\u3005\u306a\u8a00\u8a9e\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u3059\u3002CI \u306f Continuous Integration (\u7d99\u7d9a\u7684\u7d71\u5408) \u306e\u7565\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n.travis.yml \u30d5\u30a1\u30a4\u30eb\u306b\u5404\u7a2e\u8a2d\u5b9a\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p>\u516c\u5f0f\u30b5\u30a4\u30c8<br \/>\n<a href=\"https:\/\/travis-ci.org\/\" target=\"_blank\">https:\/\/travis-ci.org\/<\/a><\/p>\n<p>GitHub \u5074\u306e\u8a2d\u5b9a<br \/>\n1. \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30ec\u30dd\u30b8\u30c8\u30ea\u3092\u958b\u304d\u307e\u3059\u3002<br \/>\n2. [Setting] \u306e [Werbhooks &amp; Services] \u3092\u9078\u629e\u3057\u307e\u3059\u3002<br \/>\n3. [Add Services] \u30dc\u30bf\u30f3\u306b\u3066 [Travis CI] \u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/github1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/github1-700x332.png\" alt=\"github\" width=\"700\" height=\"332\" class=\"alignnone size-medium wp-image-517\" srcset=\"https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/github1-700x332.png 700w, https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/github1.png 1009w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/p>\n<p>Travis CI \u5074\u306e\u753b\u9762<br \/>\n<a href=\"http:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/travis_ci1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/travis_ci1-1024x737.png\" alt=\"travis_ci\" width=\"640\" height=\"461\" class=\"alignnone size-large wp-image-518\" srcset=\"https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/travis_ci1-1024x737.png 1024w, https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/travis_ci1-700x504.png 700w, https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2015\/07\/travis_ci1.png 1550w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>\u8a2d\u5b9a\u5f8c\u3001GitHub \u306e\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306b\u5909\u66f4\u304c\u767a\u751f\u3059\u308b\u3068\u3001Travis CI \u4e0a\u3067\u81ea\u52d5\u7684\u306b\u30c6\u30b9\u30c8\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u3001\u521d\u3081\u3066 Ruby \u3067\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u306e\u3067\u3001Ruby \u306e\u57fa\u672c\u7684\u306a\u30b3\u30de\u30f3\u30c9\u3084\u3001\u5468\u8fba\u6280\u8853\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002Ruby \u306e\u6587\u6cd5\u306b\u3064\u3044\u3066\u306f\u3053\u3053\u3067\u306f\u89e6\u308c\u307e\u305b\u3093\u3002 Ruby \u3068\u306f1995\u5e74\u306b\u65e5\u672c\u3067\u958b\u767a\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":515,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-452","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-unclassified"],"_links":{"self":[{"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/posts\/452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=452"}],"version-history":[{"count":59,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/posts\/452\/revisions"}],"predecessor-version":[{"id":525,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/posts\/452\/revisions\/525"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/media\/515"}],"wp:attachment":[{"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}