ruby_learner 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +58 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +65 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/new_terminal +25 -0
  13. data/bin/setup +8 -0
  14. data/docs/happy_ruby/RussOlsen_EloquentRuby_c1.pdf +0 -0
  15. data/docs/happy_ruby/RussOlsen_EloquentRuby_c5.pdf +0 -0
  16. data/docs/happy_ruby/TanoshiiRuby_v3_c23.pdf +0 -0
  17. data/docs/happy_ruby/TanoshiiRuby_v5_c1.pdf +0 -0
  18. data/docs/happy_ruby/TanoshiiRuby_v5_c2-3.pdf +0 -0
  19. data/docs/happy_ruby/c2.ipynb +479 -0
  20. data/docs/happy_ruby/c3_4.ipynb +237 -0
  21. data/docs/seminar/8-1.org +18 -0
  22. data/exe/ruby_learner +5 -0
  23. data/lib/ruby_learner/h.rb +14 -0
  24. data/lib/ruby_learner/methods.rb +131 -0
  25. data/lib/ruby_learner/random_h.rb +16 -0
  26. data/lib/ruby_learner/ruby_learner.rb +43 -0
  27. data/lib/ruby_learner/sequential_h.rb +15 -0
  28. data/lib/ruby_learner/typing_practice.rb +21 -0
  29. data/lib/ruby_learner/version.rb +3 -0
  30. data/questions/random_check/.rspec +1 -0
  31. data/questions/random_check/random_h.rb +16 -0
  32. data/questions/random_check/section_1/.rspec +1 -0
  33. data/questions/random_check/section_1/lib/answer.rb +15 -0
  34. data/questions/random_check/section_1/lib/sentence.org +9 -0
  35. data/questions/random_check/section_1/lib/workplace.rb +5 -0
  36. data/questions/random_check/section_1/spec/spec_helper.rb +100 -0
  37. data/questions/random_check/section_1/spec/workplace_spec.rb +10 -0
  38. data/questions/random_check/section_2/.rspec +1 -0
  39. data/questions/random_check/section_2/lib/answer.rb +17 -0
  40. data/questions/random_check/section_2/lib/sentence.org +12 -0
  41. data/questions/random_check/section_2/lib/workplace.rb +5 -0
  42. data/questions/random_check/section_2/spec/.rspec +1 -0
  43. data/questions/random_check/section_2/spec/spec_helper.rb +100 -0
  44. data/questions/random_check/section_2/spec/workplace_spec.rb +11 -0
  45. data/questions/sequential_check/section_1/part_1/lib/answer.rb +9 -0
  46. data/questions/sequential_check/section_1/part_1/lib/sentence.org +9 -0
  47. data/questions/sequential_check/section_1/part_1/lib/workplace.rb +5 -0
  48. data/questions/sequential_check/section_1/part_1/spec/spec_helper.rb +100 -0
  49. data/questions/sequential_check/section_1/part_1/spec/workplace_spec.rb +10 -0
  50. data/questions/sequential_check/section_1/part_2/lib/answer.rb +16 -0
  51. data/questions/sequential_check/section_1/part_2/lib/sentence.org +12 -0
  52. data/questions/sequential_check/section_1/part_2/lib/workplace.rb +5 -0
  53. data/questions/sequential_check/section_1/part_2/spec/.rspec +1 -0
  54. data/questions/sequential_check/section_1/part_2/spec/spec_helper.rb +100 -0
  55. data/questions/sequential_check/section_1/part_2/spec/workplace_spec.rb +11 -0
  56. data/ruby_learner.gemspec +41 -0
  57. data/takahashi/docs/README.org +139 -0
  58. data/takahashi/docs/drill.html +875 -0
  59. data/takahashi/docs/drill.html~ +877 -0
  60. data/takahashi/docs/drill.org +446 -0
  61. data/takahashi/docs/ruby_for_beginner.html +2642 -0
  62. data/takahashi/docs/ruby_for_beginner.org +1430 -0
  63. data/takahashi/sample_prog/answer/10_1.rb +5 -0
  64. data/takahashi/sample_prog/answer/11_1.rb +5 -0
  65. data/takahashi/sample_prog/answer/11_2.rb +4 -0
  66. data/takahashi/sample_prog/answer/1_1.rb +1 -0
  67. data/takahashi/sample_prog/answer/1_2.rb +1 -0
  68. data/takahashi/sample_prog/answer/1_3.rb +1 -0
  69. data/takahashi/sample_prog/answer/2_1.rb +5 -0
  70. data/takahashi/sample_prog/answer/2_2.rb +12 -0
  71. data/takahashi/sample_prog/answer/3_1.rb +10 -0
  72. data/takahashi/sample_prog/answer/4_1.rb +7 -0
  73. data/takahashi/sample_prog/answer/5_1.rb +6 -0
  74. data/takahashi/sample_prog/answer/5_2.rb +3 -0
  75. data/takahashi/sample_prog/answer/6_1.rb +3 -0
  76. data/takahashi/sample_prog/answer/6_2.rb +5 -0
  77. data/takahashi/sample_prog/answer/6_3.rb +5 -0
  78. data/takahashi/sample_prog/answer/6_4.rb +7 -0
  79. data/takahashi/sample_prog/answer/7_1.rb +3 -0
  80. data/takahashi/sample_prog/answer/7_2.rb +8 -0
  81. data/takahashi/sample_prog/answer/9_1.rb +3 -0
  82. data/takahashi/sample_prog/answer/9_2.rb +5 -0
  83. data/takahashi/sample_prog/answer/9_3.rb +10 -0
  84. data/takahashi/sample_prog/answer/hello.rb +3 -0
  85. data/workshop/.rspec +1 -0
  86. data/workshop/emacs.d/ac-comphist.dat +50 -0
  87. data/workshop/emacs.d/cp5022x.el +156 -0
  88. data/workshop/emacs.d/elpa/archives/gnu/archive-contents +1240 -0
  89. data/workshop/emacs.d/elpa/archives/melpa/archive-contents +2 -0
  90. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-autoloads.el +65 -0
  91. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.el +551 -0
  92. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-config.elc +0 -0
  93. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete-pkg.el +6 -0
  94. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.el +2164 -0
  95. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/auto-complete.elc +0 -0
  96. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ada-mode +72 -0
  97. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c++-mode +99 -0
  98. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/c-mode +55 -0
  99. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/caml-mode +231 -0
  100. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojure-mode +580 -0
  101. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/clojurescript-mode +475 -0
  102. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/coq-mode +278 -0
  103. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/css-mode +874 -0
  104. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/erlang-mode +216 -0
  105. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ess-julia-mode +37 -0
  106. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/go-mode +25 -0
  107. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/haskell-mode +679 -0
  108. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/java-mode +53 -0
  109. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/js-mode +148 -0
  110. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/julia-mode +37 -0
  111. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/lua-mode +21 -0
  112. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/nim-mode +70 -0
  113. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/objc-mode +161 -0
  114. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/octave-mode +46 -0
  115. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/php-mode +6144 -0
  116. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/python-mode +379 -0
  117. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/qml-mode +183 -0
  118. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ruby-mode +181 -0
  119. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scala-mode +1347 -0
  120. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/scheme-mode +216 -0
  121. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sclang-mode +1481 -0
  122. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/sh-mode +182 -0
  123. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/swift-mode +87 -0
  124. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tcl-mode +172 -0
  125. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/ts-mode +797 -0
  126. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/tuareg-mode +231 -0
  127. data/workshop/emacs.d/elpa/auto-complete-20170124.1845/dict/verilog-mode +313 -0
  128. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-autoloads.el +16 -0
  129. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults-pkg.el +2 -0
  130. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.el +90 -0
  131. data/workshop/emacs.d/elpa/better-defaults-20170613.2104/better-defaults.elc +0 -0
  132. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-autoloads.el +26 -0
  133. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode-pkg.el +2 -0
  134. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.el +877 -0
  135. data/workshop/emacs.d/elpa/haml-mode-20170923.2153/haml-mode.elc +0 -0
  136. data/workshop/emacs.d/elpa/haml-mode-readme.txt +8 -0
  137. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.el +918 -0
  138. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-light-theme.elc +0 -0
  139. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-autoloads.el +32 -0
  140. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme-pkg.el +8 -0
  141. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.el +912 -0
  142. data/workshop/emacs.d/elpa/material-theme-20171123.1040/material-theme.elc +0 -0
  143. data/workshop/emacs.d/elpa/ox-bibtex-chinese-readme.txt +21 -0
  144. data/workshop/emacs.d/elpa/popup-20160709.729/popup-autoloads.el +15 -0
  145. data/workshop/emacs.d/elpa/popup-20160709.729/popup-pkg.el +2 -0
  146. data/workshop/emacs.d/elpa/popup-20160709.729/popup.el +1432 -0
  147. data/workshop/emacs.d/elpa/popup-20160709.729/popup.elc +0 -0
  148. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-autoloads.el +33 -0
  149. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode-pkg.el +2 -0
  150. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.el +470 -0
  151. data/workshop/emacs.d/elpa/yaml-mode-20180212.1556/yaml-mode.elc +0 -0
  152. data/workshop/emacs.d/elpa/yaml-mode-readme.txt +25 -0
  153. data/workshop/emacs.d/haml-mode-master/.gitignore +1 -0
  154. data/workshop/emacs.d/haml-mode-master/.mailmap +2 -0
  155. data/workshop/emacs.d/haml-mode-master/MIT-LICENSE +20 -0
  156. data/workshop/emacs.d/haml-mode-master/README.md +47 -0
  157. data/workshop/emacs.d/haml-mode-master/haml-mode.el +887 -0
  158. data/workshop/emacs.d/iceberg_theme.el +202 -0
  159. data/workshop/emacs.d/init-open-recentf.el +133 -0
  160. data/workshop/emacs.d/init.el +229 -0
  161. data/workshop/emacs.d/inits/line-num.el +264 -0
  162. data/workshop/emacs.d/install-elisp.el +366 -0
  163. data/workshop/emacs.d/markdown-mode/markdown-mode.el +5978 -0
  164. data/workshop/emacs.d/notes +12 -0
  165. data/workshop/emacs.d/processing-mode/processing-mode.el +275 -0
  166. data/workshop/emacs.d/recentf +31 -0
  167. data/workshop/emacs.d/ruby-mode/inf-ruby.el +416 -0
  168. data/workshop/emacs.d/ruby-mode/rdoc-mode.el +130 -0
  169. data/workshop/emacs.d/ruby-mode/ruby-electric.el +205 -0
  170. data/workshop/emacs.d/ruby-mode/ruby-mode.el +1496 -0
  171. data/workshop/emacs.d/ruby-mode/ruby-style.el +78 -0
  172. data/workshop/emacs.d/ruby-mode/rubydb2x.el +104 -0
  173. data/workshop/emacs.d/ruby-mode/rubydb3x.el +115 -0
  174. data/workshop/emacs.d/ruby_learner_init.el +244 -0
  175. data/workshop/emacs.d/themes/dracula-theme.el +431 -0
  176. data/workshop/emacs.d/themes/iceberg-theme.el +205 -0
  177. data/workshop/emacs.d/themes/my-misterioso-theme.el +109 -0
  178. data/workshop/emacs.d/themes/my-wombat-theme.el +121 -0
  179. data/workshop/emacs.d/wiki-mode/wiki.el +976 -0
  180. data/workshop/emacs_help.org +34 -0
  181. data/workshop/lib/answer.rb +1 -0
  182. data/workshop/lib/sentence.org +1 -0
  183. data/workshop/lib/workplace.rb +1 -0
  184. data/workshop/restore/empty.rb +0 -0
  185. data/workshop/spec/spec_helper.rb +100 -0
  186. data/workshop/spec/workplace_spec.rb +1 -0
  187. data/workshop/training_data.txt +3 -0
  188. metadata +343 -0
@@ -0,0 +1,877 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="jp" xml:lang="jp">
5
+ <head>
6
+ <title>はじめてのRuby</title>
7
+ <!-- 2018-08-04 土 04:56 -->
8
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
9
+ <meta name="generator" content="Org-mode" />
10
+ <meta name="author" content="Shun Takahashi" />
11
+ <style type="text/css">
12
+ <!--/*--><![CDATA[/*><!--*/
13
+ .title { text-align: center; }
14
+ .todo { font-family: monospace; color: red; }
15
+ .done { color: green; }
16
+ .tag { background-color: #eee; font-family: monospace;
17
+ padding: 2px; font-size: 80%; font-weight: normal; }
18
+ .timestamp { color: #bebebe; }
19
+ .timestamp-kwd { color: #5f9ea0; }
20
+ .right { margin-left: auto; margin-right: 0px; text-align: right; }
21
+ .left { margin-left: 0px; margin-right: auto; text-align: left; }
22
+ .center { margin-left: auto; margin-right: auto; text-align: center; }
23
+ .underline { text-decoration: underline; }
24
+ #postamble p, #preamble p { font-size: 90%; margin: .2em; }
25
+ p.verse { margin-left: 3%; }
26
+ pre {
27
+ border: 1px solid #ccc;
28
+ box-shadow: 3px 3px 3px #eee;
29
+ padding: 8pt;
30
+ font-family: monospace;
31
+ overflow: auto;
32
+ margin: 1.2em;
33
+ }
34
+ pre.src {
35
+ position: relative;
36
+ overflow: visible;
37
+ padding-top: 1.2em;
38
+ }
39
+ pre.src:before {
40
+ display: none;
41
+ position: absolute;
42
+ background-color: white;
43
+ top: -10px;
44
+ right: 10px;
45
+ padding: 3px;
46
+ border: 1px solid black;
47
+ }
48
+ pre.src:hover:before { display: inline;}
49
+ pre.src-sh:before { content: 'sh'; }
50
+ pre.src-bash:before { content: 'sh'; }
51
+ pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
52
+ pre.src-R:before { content: 'R'; }
53
+ pre.src-perl:before { content: 'Perl'; }
54
+ pre.src-java:before { content: 'Java'; }
55
+ pre.src-sql:before { content: 'SQL'; }
56
+
57
+ table { border-collapse:collapse; }
58
+ caption.t-above { caption-side: top; }
59
+ caption.t-bottom { caption-side: bottom; }
60
+ td, th { vertical-align:top; }
61
+ th.right { text-align: center; }
62
+ th.left { text-align: center; }
63
+ th.center { text-align: center; }
64
+ td.right { text-align: right; }
65
+ td.left { text-align: left; }
66
+ td.center { text-align: center; }
67
+ dt { font-weight: bold; }
68
+ .footpara:nth-child(2) { display: inline; }
69
+ .footpara { display: block; }
70
+ .footdef { margin-bottom: 1em; }
71
+ .figure { padding: 1em; }
72
+ .figure p { text-align: center; }
73
+ .inlinetask {
74
+ padding: 10px;
75
+ border: 2px solid gray;
76
+ margin: 10px;
77
+ background: #ffffcc;
78
+ }
79
+ #org-div-home-and-up
80
+ { text-align: right; font-size: 70%; white-space: nowrap; }
81
+ textarea { overflow-x: auto; }
82
+ .linenr { font-size: smaller }
83
+ .code-highlighted { background-color: #ffff00; }
84
+ .org-info-js_info-navigation { border-style: none; }
85
+ #org-info-js_console-label
86
+ { font-size: 10px; font-weight: bold; white-space: nowrap; }
87
+ .org-info-js_search-highlight
88
+ { background-color: #ffff00; color: #000000; font-weight: bold; }
89
+ /*]]>*/-->
90
+ </style>
91
+ <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
92
+ <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
93
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
94
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
95
+ <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
96
+ <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
97
+ <script type="text/javascript">
98
+ /*
99
+ @licstart The following is the entire license notice for the
100
+ JavaScript code in this tag.
101
+
102
+ Copyright (C) 2012-2013 Free Software Foundation, Inc.
103
+
104
+ The JavaScript code in this tag is free software: you can
105
+ redistribute it and/or modify it under the terms of the GNU
106
+ General Public License (GNU GPL) as published by the Free Software
107
+ Foundation, either version 3 of the License, or (at your option)
108
+ any later version. The code is distributed WITHOUT ANY WARRANTY;
109
+ without even the implied warranty of MERCHANTABILITY or FITNESS
110
+ FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
111
+
112
+ As additional permission under GNU GPL version 3 section 7, you
113
+ may distribute non-source (e.g., minimized or compacted) forms of
114
+ that code without the copy of the GNU GPL normally required by
115
+ section 4, provided you include this license notice and a URL
116
+ through which recipients can access the Corresponding Source.
117
+
118
+
119
+ @licend The above is the entire license notice
120
+ for the JavaScript code in this tag.
121
+ */
122
+ <!--/*--><![CDATA[/*><!--*/
123
+ function CodeHighlightOn(elem, id)
124
+ {
125
+ var target = document.getElementById(id);
126
+ if(null != target) {
127
+ elem.cacheClassElem = elem.className;
128
+ elem.cacheClassTarget = target.className;
129
+ target.className = "code-highlighted";
130
+ elem.className = "code-highlighted";
131
+ }
132
+ }
133
+ function CodeHighlightOff(elem, id)
134
+ {
135
+ var target = document.getElementById(id);
136
+ if(elem.cacheClassElem)
137
+ elem.className = elem.cacheClassElem;
138
+ if(elem.cacheClassTarget)
139
+ target.className = elem.cacheClassTarget;
140
+ }
141
+ /*]]>*///-->
142
+ </script>
143
+ <script type="text/javascript" src="http://orgmode.org/mathjax/MathJax.js"></script>
144
+ <script type="text/javascript">
145
+ <!--/*--><![CDATA[/*><!--*/
146
+ MathJax.Hub.Config({
147
+ // Only one of the two following lines, depending on user settings
148
+ // First allows browser-native MathML display, second forces HTML/CSS
149
+ // config: ["MMLorHTML.js"], jax: ["input/TeX"],
150
+ jax: ["input/TeX", "output/HTML-CSS"],
151
+ extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js",
152
+ "TeX/noUndefined.js"],
153
+ tex2jax: {
154
+ inlineMath: [ ["\\(","\\)"] ],
155
+ displayMath: [ ['$$','$$'], ["\\[","\\]"], ["\\begin{displaymath}","\\end{displaymath}"] ],
156
+ skipTags: ["script","noscript","style","textarea","pre","code"],
157
+ ignoreClass: "tex2jax_ignore",
158
+ processEscapes: false,
159
+ processEnvironments: true,
160
+ preview: "TeX"
161
+ },
162
+ showProcessingMessages: true,
163
+ displayAlign: "center",
164
+ displayIndent: "2em",
165
+
166
+ "HTML-CSS": {
167
+ scale: 100,
168
+ availableFonts: ["STIX","TeX"],
169
+ preferredFont: "TeX",
170
+ webFont: "TeX",
171
+ imageFont: "TeX",
172
+ showMathMenu: true,
173
+ },
174
+ MMLorHTML: {
175
+ prefer: {
176
+ MSIE: "MML",
177
+ Firefox: "MML",
178
+ Opera: "HTML",
179
+ other: "HTML"
180
+ }
181
+ }
182
+ });
183
+ /*]]>*///-->
184
+ </script>
185
+ </head>
186
+ <body>
187
+ <div id="content">
188
+ <h1 class="title">はじめてのRuby</h1>
189
+ <div id="table-of-contents">
190
+ <h2>Table of Contents</h2>
191
+ <div id="text-table-of-contents">
192
+ <ul>
193
+ <li><a href="#sec-1">1. print,puts,pメソッド</a>
194
+ <ul>
195
+ <li><a href="#sec-1-1">1.1. helloruby.rb</a></li>
196
+ <li><a href="#sec-1-2">1.2. helloruby_2.rb</a></li>
197
+ <li><a href="#sec-1-3">1.3. p_method.rb</a></li>
198
+ <li><a href="#sec-1-4">1.4. kiritsubo.rb</a></li>
199
+ </ul>
200
+ </li>
201
+ <li><a href="#sec-2">2. 変数</a>
202
+ <ul>
203
+ <li><a href="#sec-2-1">2.1. area_volume.rb</a></li>
204
+ </ul>
205
+ </li>
206
+ <li><a href="#sec-3">3. 条件判断</a>
207
+ <ul>
208
+ <li><a href="#sec-3-1">3.1. greater_smaller.rb</a></li>
209
+ <li><a href="#sec-3-2">3.2. greater_smaller_else.rb</a></li>
210
+ </ul>
211
+ </li>
212
+ <li><a href="#sec-4">4. 繰り返し</a>
213
+ <ul>
214
+ <li><a href="#sec-4-1">4.1. 1_to_n.rb</a></li>
215
+ <li><a href="#sec-4-2">4.2. five_times.rb</a></li>
216
+ </ul>
217
+ </li>
218
+ <li><a href="#sec-5">5. 配列</a>
219
+ <ul>
220
+ <li><a href="#sec-5-1">5.1. 配列からオブジェクトを取り出す</a></li>
221
+ <li><a href="#sec-5-2">5.2. 配列にオブジェクトを格納する</a></li>
222
+ <li><a href="#sec-5-3">5.3. 配列の大きさ</a></li>
223
+ <li><a href="#sec-5-4">5.4. 配列と繰り返し</a></li>
224
+ </ul>
225
+ </li>
226
+ <li><a href="#sec-6">6. ハッシュ</a>
227
+ <ul>
228
+ <li><a href="#sec-6-1">6.1. シンボル</a></li>
229
+ <li><a href="#sec-6-2">6.2. ハッシュの操作</a></li>
230
+ </ul>
231
+ </li>
232
+ <li><a href="#sec-7">7. 正規表現</a>
233
+ <ul>
234
+ <li><a href="#sec-7-1">7.1. パターンとマッチング</a></li>
235
+ </ul>
236
+ </li>
237
+ <li><a href="#sec-8">8. コマンドラインからのデータの入力</a>
238
+ <ul>
239
+ <li><a href="#sec-8-1">8.1. List3.1 print_argv.rb</a></li>
240
+ <li><a href="#sec-8-2">8.2. List3.3 arg_arith.rb</a></li>
241
+ </ul>
242
+ </li>
243
+ <li><a href="#sec-9">9. ファイルからの読み込み</a>
244
+ <ul>
245
+ <li><a href="#sec-9-1">9.1. read_text.rb</a></li>
246
+ <li><a href="#sec-9-2">9.2. read_line.rb</a></li>
247
+ <li><a href="#sec-9-3">9.3. simple_grep.rb</a></li>
248
+ </ul>
249
+ </li>
250
+ <li><a href="#sec-10">10. メソッドの作成</a>
251
+ <ul>
252
+ <li><a href="#sec-10-1">10.1. hello_ruby2.rb</a></li>
253
+ </ul>
254
+ </li>
255
+ <li><a href="#sec-11">11. 別のファイルを取り込む</a>
256
+ <ul>
257
+ <li><a href="#sec-11-1">11.1. Rubyの標準ライブラリ</a></li>
258
+ </ul>
259
+ </li>
260
+ </ul>
261
+ </div>
262
+ </div>
263
+
264
+
265
+ <div id="outline-container-sec-1" class="outline-2">
266
+ <h2 id="sec-1"><span class="section-number-2">1</span> print,puts,pメソッド</h2>
267
+ <div class="outline-text-2" id="text-1">
268
+ </div><div id="outline-container-sec-1-1" class="outline-3">
269
+ <h3 id="sec-1-1"><span class="section-number-3">1.1</span> helloruby.rb</h3>
270
+ <div class="outline-text-3" id="text-1-1">
271
+ <p>
272
+ 「Hello, Ruby.」という文字列を出力するプログラムを作成せよ
273
+ </p>
274
+
275
+ <div class="org-src-container">
276
+
277
+ <pre class="src src-ruby">print('Hello, Ruby.\n')
278
+ </pre>
279
+ </div>
280
+
281
+ <pre class="example">
282
+ Hello, Ruby.
283
+ </pre>
284
+ </div>
285
+ </div>
286
+
287
+ <div id="outline-container-sec-1-2" class="outline-3">
288
+ <h3 id="sec-1-2"><span class="section-number-3">1.2</span> helloruby_2.rb</h3>
289
+ <div class="outline-text-3" id="text-1-2">
290
+ <p>
291
+ 「Hello, "Ruby".」という文字列を出力するプログラムを作成せよ
292
+ </p>
293
+
294
+ <div class="org-src-container">
295
+
296
+ <pre class="src src-ruby">print("Hello, \"Ruby\".\n")
297
+ </pre>
298
+ </div>
299
+
300
+ <pre class="example">
301
+ &gt; helloruby_2.rb
302
+ Hello,"Ruby".
303
+ </pre>
304
+ </div>
305
+ </div>
306
+
307
+ <div id="outline-container-sec-1-3" class="outline-3">
308
+ <h3 id="sec-1-3"><span class="section-number-3">1.3</span> p_method.rb</h3>
309
+ <div class="outline-text-3" id="text-1-3">
310
+ <p>
311
+ 「"Hello,\n\tRuby."」という文字列を出力するプログラムを作成せよ
312
+ </p>
313
+
314
+ <div class="org-src-container">
315
+
316
+ <pre class="src src-ruby">p "Hello,\n\tRuby."
317
+ </pre>
318
+ </div>
319
+ </div>
320
+ </div>
321
+
322
+
323
+
324
+ <div id="outline-container-sec-1-4" class="outline-3">
325
+ <h3 id="sec-1-4"><span class="section-number-3">1.4</span> kiritsubo.rb</h3>
326
+ <div class="outline-text-3" id="text-1-4">
327
+ </div>
328
+ </div>
329
+ </div>
330
+
331
+ <div id="outline-container-sec-2" class="outline-2">
332
+ <h2 id="sec-2"><span class="section-number-2">2</span> 変数</h2>
333
+ <div class="outline-text-2" id="text-2">
334
+ </div><div id="outline-container-sec-2-1" class="outline-3">
335
+ <h3 id="sec-2-1"><span class="section-number-3">2.1</span> area_volume.rb</h3>
336
+ <div class="outline-text-3" id="text-2-1">
337
+ <p>
338
+ 3つの数値x、y、zを受け取り、縦x、横y、高さzの直方体の表面積と体積を求めるプログラム
339
+ </p>
340
+
341
+ <div class="org-src-container">
342
+
343
+ <pre class="src src-ruby">x = ARGV[0].to_i
344
+ y = ARGV[1].to_i
345
+ z = ARGV[2].to_i
346
+
347
+ area = (x*y + y*z + z*x) * 2
348
+ volume = x * y * z
349
+
350
+ print "表面積=", area, "\n"
351
+ print "体積=" volume, "\n"
352
+ </pre>
353
+ </div>
354
+
355
+ <pre class="example">
356
+ &gt; ruby area_volume.rb 10 20 30
357
+ 表面積=2200
358
+ 体積=6000
359
+ </pre>
360
+ </div>
361
+ </div>
362
+ </div>
363
+
364
+ <div id="outline-container-sec-3" class="outline-2">
365
+ <h2 id="sec-3"><span class="section-number-2">3</span> 条件判断</h2>
366
+ <div class="outline-text-2" id="text-3">
367
+ </div><div id="outline-container-sec-3-1" class="outline-3">
368
+ <h3 id="sec-3-1"><span class="section-number-3">3.1</span> greater_smaller.rb</h3>
369
+ <div class="outline-text-3" id="text-3-1">
370
+ <p>
371
+ 数値を1つ引数として受け取り、それが10以上ならば「greater」、9以下ならば「smaller」と出力するプログラム
372
+ </p>
373
+
374
+ <div class="org-src-container">
375
+
376
+ <pre class="src src-ruby">a = ARGV[0].to_i
377
+
378
+ if a &gt;= 10
379
+ print "greater\n"
380
+ end
381
+ if a &lt;= 9
382
+ print "smaller\n"
383
+ end
384
+ </pre>
385
+ </div>
386
+
387
+ <pre class="example">
388
+ &gt;ruby greater_smaller_else.rb 20
389
+ greater
390
+
391
+ &gt;ruby greater_smaller_else.rb 5
392
+ smaller
393
+ </pre>
394
+ </div>
395
+ </div>
396
+
397
+ <div id="outline-container-sec-3-2" class="outline-3">
398
+ <h3 id="sec-3-2"><span class="section-number-3">3.2</span> greater_smaller_else.rb</h3>
399
+ <div class="outline-text-3" id="text-3-2">
400
+ <p>
401
+ List1.6のプログラムと同じ処理を、elseを用いて実行するプログラム
402
+ </p>
403
+
404
+ <div class="org-src-container">
405
+
406
+ <pre class="src src-ruby">a = ARGV[0].to_i
407
+
408
+ if a &gt;= 10
409
+ print "greater\n"
410
+ else
411
+ print "smaller\n"
412
+ </pre>
413
+ </div>
414
+
415
+ <pre class="example">
416
+ &gt;ruby greater_smaller_else.rb 20
417
+ greater
418
+
419
+ &gt;ruby greater_smaller_else.rb 5
420
+ smaller
421
+ </pre>
422
+ </div>
423
+ </div>
424
+ </div>
425
+
426
+ <div id="outline-container-sec-4" class="outline-2">
427
+ <h2 id="sec-4"><span class="section-number-2">4</span> 繰り返し</h2>
428
+ <div class="outline-text-2" id="text-4">
429
+ </div><div id="outline-container-sec-4-1" class="outline-3">
430
+ <h3 id="sec-4-1"><span class="section-number-3">4.1</span> 1_to_n.rb</h3>
431
+ <div class="outline-text-3" id="text-4-1">
432
+ <p>
433
+ 入力された1つの数値nを引数として受け取り、1からnまでの数を順番に表示するプログラムを作成せよ
434
+ </p>
435
+
436
+ <div class="org-src-container">
437
+
438
+ <pre class="src src-ruby">n = ARGV[0].to_i
439
+ i = 1
440
+ while i &lt;= n
441
+ print i, "\n"
442
+ i = i + 1
443
+ end
444
+ </pre>
445
+ </div>
446
+
447
+ <pre class="example">
448
+ &gt; ruby 1_to_n.rb 5
449
+ 1
450
+ 2
451
+ 3
452
+ 4
453
+ 5
454
+ </pre>
455
+ </div>
456
+ </div>
457
+
458
+
459
+ <div id="outline-container-sec-4-2" class="outline-3">
460
+ <h3 id="sec-4-2"><span class="section-number-3">4.2</span> five_times.rb</h3>
461
+ <div class="outline-text-3" id="text-4-2">
462
+ <p>
463
+ 「All work and no play makes Jack a dull boy.」と5行表示するプログラム
464
+ </p>
465
+
466
+ <div class="org-src-container">
467
+
468
+ <pre class="src src-ruby">5.times do
469
+ print "All work and no play makes Jack a dull boy."
470
+ end
471
+ </pre>
472
+ </div>
473
+ </div>
474
+ </div>
475
+ </div>
476
+
477
+
478
+
479
+
480
+ <div id="outline-container-sec-5" class="outline-2">
481
+ <h2 id="sec-5"><span class="section-number-2">5</span> 配列</h2>
482
+ <div class="outline-text-2" id="text-5">
483
+ </div><div id="outline-container-sec-5-1" class="outline-3">
484
+ <h3 id="sec-5-1"><span class="section-number-3">5.1</span> 配列からオブジェクトを取り出す</h3>
485
+ <div class="outline-text-3" id="text-5-1">
486
+ <p>
487
+ 配列のn番目の要素を取り出し、表示するプログラム
488
+ </p>
489
+
490
+ <div class="org-src-container">
491
+
492
+ <pre class="src src-ruby">names = ["小林", "林", "高野", "森岡"]
493
+
494
+ print names[ARGV[0]]
495
+ </pre>
496
+ </div>
497
+
498
+ <div class="org-src-container">
499
+
500
+ <pre class="src src-ruby">&gt;ruby answer.rb 0
501
+ 小林
502
+ </pre>
503
+ </div>
504
+ </div>
505
+ </div>
506
+
507
+ <div id="outline-container-sec-5-2" class="outline-3">
508
+ <h3 id="sec-5-2"><span class="section-number-3">5.2</span> 配列にオブジェクトを格納する</h3>
509
+ <div class="outline-text-3" id="text-5-2">
510
+ <p>
511
+ 配列の先頭の要素をコマンドラインに入力した要素に変更するプログラム
512
+ </p>
513
+
514
+ <div class="org-src-container">
515
+
516
+ <pre class="src src-ruby">nums = [1, 2, 3]
517
+
518
+ nums[0] = ARGV[0]
519
+
520
+ print nums
521
+ </pre>
522
+ </div>
523
+
524
+
525
+ <pre class="example">
526
+ &gt; ruby answer.rb 5
527
+ [5, 2, 3]
528
+ </pre>
529
+ </div>
530
+ </div>
531
+
532
+ <div id="outline-container-sec-5-3" class="outline-3">
533
+ <h3 id="sec-5-3"><span class="section-number-3">5.3</span> 配列の大きさ</h3>
534
+ <div class="outline-text-3" id="text-5-3">
535
+ <p>
536
+ 配列を表示し、その配列の大きさも表示するプログラムを作成せよ
537
+ </p>
538
+
539
+ <div class="org-src-container">
540
+
541
+ <pre class="src src-ruby">names =
542
+
543
+ print names, "\n"
544
+
545
+ print names.size
546
+ </pre>
547
+ </div>
548
+ </div>
549
+ </div>
550
+
551
+
552
+ <div id="outline-container-sec-5-4" class="outline-3">
553
+ <h3 id="sec-5-4"><span class="section-number-3">5.4</span> 配列と繰り返し</h3>
554
+ <div class="outline-text-3" id="text-5-4">
555
+ <p>
556
+ 配列全体を表示してから、配列の要素を順に表示するプログラム
557
+ </p>
558
+
559
+ <div class="org-src-container">
560
+
561
+ <pre class="src src-ruby">names = ["小林", "林", "高野", "森岡"]
562
+
563
+ print names, "\n"
564
+
565
+ names.each do |n|
566
+ puts n
567
+ end
568
+ </pre>
569
+ </div>
570
+
571
+ <pre class="example">
572
+ &gt; ruby answer.rb
573
+ ["小林", "林", "高野", "森岡"]
574
+ 小林
575
+
576
+ 高野
577
+ 森岡
578
+ </pre>
579
+ </div>
580
+ </div>
581
+ </div>
582
+
583
+ <div id="outline-container-sec-6" class="outline-2">
584
+ <h2 id="sec-6"><span class="section-number-2">6</span> ハッシュ</h2>
585
+ <div class="outline-text-2" id="text-6">
586
+ </div><div id="outline-container-sec-6-1" class="outline-3">
587
+ <h3 id="sec-6-1"><span class="section-number-3">6.1</span> シンボル</h3>
588
+ <div class="outline-text-3" id="text-6-1">
589
+ <p>
590
+ コマンドラインから文字列を受け取り、シンボルに変換して表示するプログラム
591
+ </p>
592
+
593
+ <div class="org-src-container">
594
+
595
+ <pre class="src src-ruby">n = ARGV[0]
596
+
597
+ p n.to_sym
598
+ </pre>
599
+ </div>
600
+
601
+ <pre class="example">
602
+ &gt; ruby answer.rb hash
603
+ :hash
604
+ </pre>
605
+ </div>
606
+ </div>
607
+
608
+ <div id="outline-container-sec-6-2" class="outline-3">
609
+ <h3 id="sec-6-2"><span class="section-number-3">6.2</span> ハッシュの操作</h3>
610
+ <div class="outline-text-3" id="text-6-2">
611
+ <p>
612
+ :name, :furiganaというそれぞれのキーに"高橋", "タカハシ"というオブジェクトが格納されているハッシュを表示、さらに:telというキーに"000-1234-5678"を格納して再度表示するプログラム
613
+ </p>
614
+
615
+ <div class="org-src-container">
616
+
617
+ <pre class="src src-ruby">address = {name: "高橋", furigana: "タカハシ"}
618
+
619
+ puts address
620
+
621
+ address[:tel] = "000-1234-5678"
622
+
623
+ puts address
624
+ </pre>
625
+ </div>
626
+
627
+ <pre class="example">
628
+ &gt; ruby answer.rb
629
+ {:name=&gt;"高橋", :furigana=&gt;"タカハシ"}
630
+ {:name=&gt;"高橋", :furigana=&gt;"タカハシ", :tel=&gt;"000-1234-5678"}
631
+ </pre>
632
+ </div>
633
+ </div>
634
+ </div>
635
+
636
+
637
+ <div id="outline-container-sec-7" class="outline-2">
638
+ <h2 id="sec-7"><span class="section-number-2">7</span> 正規表現</h2>
639
+ <div class="outline-text-2" id="text-7">
640
+ </div><div id="outline-container-sec-7-1" class="outline-3">
641
+ <h3 id="sec-7-1"><span class="section-number-3">7.1</span> パターンとマッチング</h3>
642
+ <div class="outline-text-3" id="text-7-1">
643
+ <div class="org-src-container">
644
+
645
+ <pre class="src src-ruby"></pre>
646
+ </div>
647
+ </div>
648
+ </div>
649
+ </div>
650
+
651
+ <div id="outline-container-sec-8" class="outline-2">
652
+ <h2 id="sec-8"><span class="section-number-2">8</span> コマンドラインからのデータの入力</h2>
653
+ <div class="outline-text-2" id="text-8">
654
+ </div><div id="outline-container-sec-8-1" class="outline-3">
655
+ <h3 id="sec-8-1"><span class="section-number-3">8.1</span> List3.1 print_argv.rb</h3>
656
+ <div class="outline-text-3" id="text-8-1">
657
+ <p>
658
+ コマンドラインから引数を5つ入力として受け取り、出力するプログラム
659
+ </p>
660
+
661
+ <div class="org-src-container">
662
+
663
+ <pre class="src src-ruby"># List3.1 print_argv.rb
664
+ puts "最初の引数: #{ARGV[0]}"
665
+ puts "2番目の引数: #{ARGV[1]}"
666
+ puts "3番目の引数: #{ARGV[2]}"
667
+ puts "4番目の引数: #{ARGV[3]}"
668
+ puts "5番目の引数: #{ARGV[4]}"
669
+ </pre>
670
+ </div>
671
+
672
+ <pre class="example">
673
+ 実行例
674
+ &gt; ruby print_argv.rb 1st 2nd 3rd 4th 5th
675
+ 最初の引数: 1st
676
+ 2番目の引数: 2nd
677
+ 3番目の引数: 3rd
678
+ 4番目の引数: 4th
679
+ 5番目の引数: 5th
680
+ </pre>
681
+ </div>
682
+ </div>
683
+
684
+
685
+
686
+ <div id="outline-container-sec-8-2" class="outline-3">
687
+ <h3 id="sec-8-2"><span class="section-number-3">8.2</span> List3.3 arg_arith.rb</h3>
688
+ <div class="outline-text-3" id="text-8-2">
689
+ <p>
690
+ コマンドラインから数値を2つ受け取り、和、差、積、商を表示するプログラム
691
+ </p>
692
+
693
+ <div class="org-src-container">
694
+
695
+ <pre class="src src-ruby">num0 = ARGV[0].to_i
696
+ num1 = ARGV[1].to_i
697
+
698
+ puts "#{num0 + num1}"
699
+ puts "#{num0 - num1}"
700
+ puts "#{num0 * num1}"
701
+ puts "#{num0 / num1}"
702
+ </pre>
703
+ </div>
704
+
705
+ <pre class="example">
706
+ &gt; ruby answer.rb 5 3
707
+ 8
708
+ 2
709
+ 15
710
+ 1
711
+ </pre>
712
+ </div>
713
+ </div>
714
+ </div>
715
+
716
+ <div id="outline-container-sec-9" class="outline-2">
717
+ <h2 id="sec-9"><span class="section-number-2">9</span> ファイルからの読み込み</h2>
718
+ <div class="outline-text-2" id="text-9">
719
+ </div><div id="outline-container-sec-9-1" class="outline-3">
720
+ <h3 id="sec-9-1"><span class="section-number-3">9.1</span> read_text.rb</h3>
721
+ <div class="outline-text-3" id="text-9-1">
722
+ <p>
723
+ コマンドラインからファイル名を受け取り、該当ファイルのテキストデータを表示するプログラム
724
+ </p>
725
+
726
+ <div class="org-src-container">
727
+
728
+ <pre class="src src-ruby">filename = ARGV[0]
729
+ text = File.read(filename)
730
+ print text
731
+ </pre>
732
+ </div>
733
+
734
+ <pre class="example">
735
+ &gt;ruby answer.rb [filename]
736
+ [text]
737
+ </pre>
738
+ </div>
739
+ </div>
740
+
741
+
742
+ <div id="outline-container-sec-9-2" class="outline-3">
743
+ <h3 id="sec-9-2"><span class="section-number-3">9.2</span> read_line.rb</h3>
744
+ <div class="outline-text-3" id="text-9-2">
745
+ <p>
746
+ コマンドラインからファイル名を受け取り、該当ファイルのテキストデータを1行ずつ表示すつプログラム
747
+ </p>
748
+
749
+ <div class="org-src-container">
750
+
751
+ <pre class="src src-ruby">filename = ARGV[0]
752
+ file = File.open(filename)
753
+ file.each_line do |line|
754
+ print line
755
+ end
756
+ </pre>
757
+ </div>
758
+
759
+ <pre class="example">
760
+ </pre>
761
+ </div>
762
+ </div>
763
+
764
+
765
+ <div id="outline-container-sec-9-3" class="outline-3">
766
+ <h3 id="sec-9-3"><span class="section-number-3">9.3</span> simple_grep.rb</h3>
767
+ <div class="outline-text-3" id="text-9-3">
768
+ <p>
769
+ 入力したテキストデータの中から、正規表現で指定した特定のパターンにマッチする行を出力するプログラム
770
+ </p>
771
+
772
+ <div class="org-src-container">
773
+
774
+ <pre class="src src-ruby">pattern = Regexp.new(ARGV[0])
775
+ filename = ARGV[1]
776
+
777
+ file = File.open(filename)
778
+ file.each_line do |line|
779
+ if pattern =~ line
780
+ print line
781
+ end
782
+ end
783
+ file.close
784
+ </pre>
785
+ </div>
786
+
787
+ <pre class="example">
788
+ &gt;ruby answer.rb [pattern] [filename]
789
+ </pre>
790
+ </div>
791
+ </div>
792
+ </div>
793
+
794
+ <div id="outline-container-sec-10" class="outline-2">
795
+ <h2 id="sec-10"><span class="section-number-2">10</span> メソッドの作成</h2>
796
+ <div class="outline-text-2" id="text-10">
797
+ </div><div id="outline-container-sec-10-1" class="outline-3">
798
+ <h3 id="sec-10-1"><span class="section-number-3">10.1</span> hello_ruby2.rb</h3>
799
+ <div class="outline-text-3" id="text-10-1">
800
+ <p>
801
+ 「Hello, Ruby.」と表示するメソッドhelloを用いて、
802
+ </p>
803
+
804
+
805
+ <div class="org-src-container">
806
+
807
+ <pre class="src src-ruby">def hello
808
+ puts "Hello, Ruby."
809
+ end
810
+
811
+ hello()
812
+ </pre>
813
+ </div>
814
+
815
+ <pre class="example">
816
+ &gt; ruby hello_ruby2.rb
817
+ Hello, Ruby.
818
+ </pre>
819
+ </div>
820
+ </div>
821
+ </div>
822
+
823
+
824
+
825
+
826
+
827
+ <div id="outline-container-sec-11" class="outline-2">
828
+ <h2 id="sec-11"><span class="section-number-2">11</span> 別のファイルを取り込む</h2>
829
+ <div class="outline-text-2" id="text-11">
830
+ <div class="org-src-container">
831
+
832
+ <pre class="src src-ruby">def simple_grep(pattern, filename)
833
+ file = File.open(filename)
834
+ file.each_line do |line|
835
+ if pattern =~ line
836
+ print line
837
+ end
838
+ end
839
+ file.close
840
+ end
841
+ </pre>
842
+ </div>
843
+
844
+ <div class="org-src-container">
845
+
846
+ <pre class="src src-ruby">require_relative "grep"
847
+
848
+ pattern = Regexp.new(ARGV[0])
849
+ filename = ARGV[1]
850
+ simple_grep(pattern, filename)
851
+ </pre>
852
+ </div>
853
+ </div>
854
+
855
+ <div id="outline-container-sec-11-1" class="outline-3">
856
+ <h3 id="sec-11-1"><span class="section-number-3">11.1</span> Rubyの標準ライブラリ</h3>
857
+ <div class="outline-text-3" id="text-11-1">
858
+ <div class="org-src-container">
859
+
860
+ <pre class="src src-ruby">require "date"
861
+
862
+ days = Date.today - Date.new(1993, 2, 24)
863
+ puts(days.to_i)
864
+ </pre>
865
+ </div>
866
+ </div>
867
+ </div>
868
+ </div>
869
+ </div>
870
+ <div id="postamble" class="status">
871
+ <p class="author">Author: Shun Takahashi</p>
872
+ <p class="date">Created: 2018-08-04 土 04:56</p>
873
+ <p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 25.3.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10)</p>
874
+ <p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
875
+ </div>
876
+ </body>
877
+ </html>