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,479 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "toc": "true"
7
+ },
8
+ "source": [
9
+ "# Table of Contents\n",
10
+ " <p><div class=\"lev1 toc-item\"><a href=\"#テキスト\" data-toc-modified-id=\"テキスト-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>テキスト</a></div><div class=\"lev1 toc-item\"><a href=\"#文字出力\" data-toc-modified-id=\"文字出力-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>文字出力</a></div><div class=\"lev1 toc-item\"><a href=\"#数値\" data-toc-modified-id=\"数値-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>数値</a></div><div class=\"lev1 toc-item\"><a href=\"#変数\" data-toc-modified-id=\"変数-4\"><span class=\"toc-item-num\">4&nbsp;&nbsp;</span>変数</a></div><div class=\"lev1 toc-item\"><a href=\"#コメント\" data-toc-modified-id=\"コメント-5\"><span class=\"toc-item-num\">5&nbsp;&nbsp;</span>コメント</a></div><div class=\"lev1 toc-item\"><a href=\"#制御構造\" data-toc-modified-id=\"制御構造-6\"><span class=\"toc-item-num\">6&nbsp;&nbsp;</span>制御構造</a></div><div class=\"lev2 toc-item\"><a href=\"#条件判断(if_then_else)\" data-toc-modified-id=\"条件判断(if_then_else)-61\"><span class=\"toc-item-num\">6.1&nbsp;&nbsp;</span>条件判断(if_then_else)</a></div><div class=\"lev2 toc-item\"><a href=\"#繰り返し(loop)\" data-toc-modified-id=\"繰り返し(loop)-62\"><span class=\"toc-item-num\">6.2&nbsp;&nbsp;</span>繰り返し(loop)</a></div><div class=\"lev1 toc-item\"><a href=\"#課題\" data-toc-modified-id=\"課題-7\"><span class=\"toc-item-num\">7&nbsp;&nbsp;</span>課題</a></div><div class=\"lev2 toc-item\"><a href=\"#helloの変形(hello_name.rb)\" data-toc-modified-id=\"helloの変形(hello_name.rb)-71\"><span class=\"toc-item-num\">7.1&nbsp;&nbsp;</span>helloの変形(hello_name.rb)</a></div><div class=\"lev2 toc-item\"><a href=\"#8回愛してる(hello_8.rb)\" data-toc-modified-id=\"8回愛してる(hello_8.rb)-72\"><span class=\"toc-item-num\">7.2&nbsp;&nbsp;</span>8回愛してる(hello_8.rb)</a></div><div class=\"lev2 toc-item\"><a href=\"#今日の日付\" data-toc-modified-id=\"今日の日付-73\"><span class=\"toc-item-num\">7.3&nbsp;&nbsp;</span>今日の日付</a></div>"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "markdown",
15
+ "metadata": {},
16
+ "source": [
17
+ "# テキスト\n",
18
+ "\n",
19
+ "* [たのしいruby c1](TanoshiiRuby_v5_c1.pdf)"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "markdown",
24
+ "metadata": {},
25
+ "source": [
26
+ "# 文字出力\n",
27
+ "\n",
28
+ "* print\n",
29
+ "* ダブルコーテーションとシングル\n",
30
+ "* puts, p\n"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": 24,
36
+ "metadata": {},
37
+ "outputs": [
38
+ {
39
+ "name": "stdout",
40
+ "output_type": "stream",
41
+ "text": [
42
+ "Hello, Ruby.\n"
43
+ ]
44
+ }
45
+ ],
46
+ "source": [
47
+ "# print_hello.rb\n",
48
+ "print(\"Hello, Ruby.\\n\")"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": 3,
54
+ "metadata": {},
55
+ "outputs": [
56
+ {
57
+ "name": "stdout",
58
+ "output_type": "stream",
59
+ "text": [
60
+ "Hello, \n",
61
+ "Ruby\n",
62
+ "!\n"
63
+ ]
64
+ }
65
+ ],
66
+ "source": [
67
+ "print(\"Hello, \\nRuby\\n!\\n\")"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "code",
72
+ "execution_count": 4,
73
+ "metadata": {},
74
+ "outputs": [
75
+ {
76
+ "name": "stdout",
77
+ "output_type": "stream",
78
+ "text": [
79
+ "Hello, \"Ruby.\"\n"
80
+ ]
81
+ }
82
+ ],
83
+ "source": [
84
+ "print(\"Hello, \\\"Ruby.\\\"\\n\")"
85
+ ]
86
+ },
87
+ {
88
+ "cell_type": "code",
89
+ "execution_count": 5,
90
+ "metadata": {},
91
+ "outputs": [
92
+ {
93
+ "name": "stdout",
94
+ "output_type": "stream",
95
+ "text": [
96
+ "Hello, \\\"Ruby.\\\"\\n"
97
+ ]
98
+ }
99
+ ],
100
+ "source": [
101
+ "print('Hello, \\\"Ruby.\\\"\\n')"
102
+ ]
103
+ },
104
+ {
105
+ "cell_type": "code",
106
+ "execution_count": 23,
107
+ "metadata": {},
108
+ "outputs": [
109
+ {
110
+ "name": "stdout",
111
+ "output_type": "stream",
112
+ "text": [
113
+ "Hello, \n",
114
+ "\tRuby.\n",
115
+ "\"Hello, \\n\\tRuby.\"\n"
116
+ ]
117
+ },
118
+ {
119
+ "data": {
120
+ "text/plain": [
121
+ "\"Hello, \\n\\tRuby.\""
122
+ ]
123
+ },
124
+ "execution_count": 23,
125
+ "metadata": {},
126
+ "output_type": "execute_result"
127
+ }
128
+ ],
129
+ "source": [
130
+ "# puts_and_p.rb\n",
131
+ "puts \"Hello, \\n\\tRuby.\"\n",
132
+ "p \"Hello, \\n\\tRuby.\""
133
+ ]
134
+ },
135
+ {
136
+ "cell_type": "markdown",
137
+ "metadata": {},
138
+ "source": [
139
+ "# 数値"
140
+ ]
141
+ },
142
+ {
143
+ "cell_type": "code",
144
+ "execution_count": 20,
145
+ "metadata": {},
146
+ "outputs": [
147
+ {
148
+ "name": "stdout",
149
+ "output_type": "stream",
150
+ "text": [
151
+ "1+1=2\n"
152
+ ]
153
+ }
154
+ ],
155
+ "source": [
156
+ "# arith.rb\n",
157
+ "print(\"1+1=\",1+1,\"\\n\")"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "code",
162
+ "execution_count": 9,
163
+ "metadata": {},
164
+ "outputs": [
165
+ {
166
+ "name": "stdout",
167
+ "output_type": "stream",
168
+ "text": [
169
+ "sin(3.1415) = 9.265358966049024e-05\n",
170
+ "sqrt(10000) = 100.0\n"
171
+ ]
172
+ }
173
+ ],
174
+ "source": [
175
+ "include Math\n",
176
+ "print(\"sin(3.1415) = \", sin(3.1415),\"\\n\")\n",
177
+ "print(\"sqrt(10000) = \", sqrt(10000),\"\\n\")"
178
+ ]
179
+ },
180
+ {
181
+ "cell_type": "markdown",
182
+ "metadata": {},
183
+ "source": [
184
+ "# 変数"
185
+ ]
186
+ },
187
+ {
188
+ "cell_type": "code",
189
+ "execution_count": 31,
190
+ "metadata": {},
191
+ "outputs": [
192
+ {
193
+ "name": "stdout",
194
+ "output_type": "stream",
195
+ "text": [
196
+ "表面積=2200\n",
197
+ "体積 =6000\n"
198
+ ]
199
+ }
200
+ ],
201
+ "source": [
202
+ "# area_volume.rb\n",
203
+ "x = 10\n",
204
+ "y = 20\n",
205
+ "z = 30\n",
206
+ "area = (x*y + y*z + z*x)*2\n",
207
+ "volume = x*y*z\n",
208
+ "print(\"表面積=\", area, \"\\n\")\n",
209
+ "print(\"体積 =\", volume, \"\\n\")"
210
+ ]
211
+ },
212
+ {
213
+ "cell_type": "code",
214
+ "execution_count": 32,
215
+ "metadata": {
216
+ "scrolled": true
217
+ },
218
+ "outputs": [
219
+ {
220
+ "name": "stdout",
221
+ "output_type": "stream",
222
+ "text": [
223
+ "表面積= 2200\n",
224
+ "体積 = 6000\n"
225
+ ]
226
+ }
227
+ ],
228
+ "source": [
229
+ "print(\"表面積= #{area}\\n\")\n",
230
+ "print(\"体積 = #{volume}\\n\")"
231
+ ]
232
+ },
233
+ {
234
+ "cell_type": "markdown",
235
+ "metadata": {},
236
+ "source": [
237
+ "# コメント\n",
238
+ "\n",
239
+ "* #以降がコメント\n",
240
+ "* ブロックコメント(=begin_=end)"
241
+ ]
242
+ },
243
+ {
244
+ "cell_type": "markdown",
245
+ "metadata": {},
246
+ "source": [
247
+ "# 制御構造\n",
248
+ "## 条件判断(if_then_else)\n"
249
+ ]
250
+ },
251
+ {
252
+ "cell_type": "code",
253
+ "execution_count": 13,
254
+ "metadata": {},
255
+ "outputs": [
256
+ {
257
+ "name": "stdout",
258
+ "output_type": "stream",
259
+ "text": [
260
+ "bigger\n"
261
+ ]
262
+ }
263
+ ],
264
+ "source": [
265
+ "# bigger_smaller.rb\n",
266
+ "a = 20\n",
267
+ "if a >= 10\n",
268
+ " print(\"bigger\\n\")\n",
269
+ "else\n",
270
+ " print(\"smaller\\n\")\n",
271
+ "end"
272
+ ]
273
+ },
274
+ {
275
+ "cell_type": "markdown",
276
+ "metadata": {},
277
+ "source": [
278
+ "## 繰り返し(loop)\n",
279
+ "* while\n",
280
+ "* times\n",
281
+ "* each"
282
+ ]
283
+ },
284
+ {
285
+ "cell_type": "code",
286
+ "execution_count": 17,
287
+ "metadata": {},
288
+ "outputs": [
289
+ {
290
+ "name": "stdout",
291
+ "output_type": "stream",
292
+ "text": [
293
+ "1\n",
294
+ "2\n",
295
+ "3\n",
296
+ "4\n",
297
+ "5\n",
298
+ "6\n",
299
+ "7\n",
300
+ "8\n",
301
+ "9\n",
302
+ "10\n"
303
+ ]
304
+ }
305
+ ],
306
+ "source": [
307
+ "# while_loop.rb\n",
308
+ "i = 1 \n",
309
+ "while i<=10\n",
310
+ " print(i, \"\\n\")\n",
311
+ " i += 1\n",
312
+ "end"
313
+ ]
314
+ },
315
+ {
316
+ "cell_type": "code",
317
+ "execution_count": 18,
318
+ "metadata": {},
319
+ "outputs": [
320
+ {
321
+ "name": "stdout",
322
+ "output_type": "stream",
323
+ "text": [
324
+ "hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. hello. "
325
+ ]
326
+ },
327
+ {
328
+ "data": {
329
+ "text/plain": [
330
+ "100"
331
+ ]
332
+ },
333
+ "execution_count": 18,
334
+ "metadata": {},
335
+ "output_type": "execute_result"
336
+ }
337
+ ],
338
+ "source": [
339
+ "# times_loop.rb\n",
340
+ "100.times {\n",
341
+ " print \"hello. \"\n",
342
+ "}"
343
+ ]
344
+ },
345
+ {
346
+ "cell_type": "markdown",
347
+ "metadata": {},
348
+ "source": [
349
+ "# 課題"
350
+ ]
351
+ },
352
+ {
353
+ "cell_type": "markdown",
354
+ "metadata": {},
355
+ "source": [
356
+ "## helloの変形(hello_name.rb)\n",
357
+ "自分の名前(例えば,name = 'bob')を変数に入れて\n",
358
+ "> Hello, bob!\n",
359
+ "\n",
360
+ "と返すようにしなさい."
361
+ ]
362
+ },
363
+ {
364
+ "cell_type": "markdown",
365
+ "metadata": {},
366
+ "source": []
367
+ },
368
+ {
369
+ "cell_type": "markdown",
370
+ "metadata": {
371
+ "collapsed": true
372
+ },
373
+ "source": [
374
+ "## 8回愛してる(hello_8.rb)\n",
375
+ "\n",
376
+ "> Hello, bob!\n",
377
+ "\n",
378
+ "を8回繰り返すようにmain loopを書き換えなさい.さらに,\n",
379
+ "```bash\n",
380
+ "ruby hello_8.rb 28s  Mon Sep 4 17:25:47 2017\n",
381
+ " 0 Hello, bob.\n",
382
+ " 1 Hello, bob.\n",
383
+ " 2 Hello, bob.\n",
384
+ " 3 Hello, bob.\n",
385
+ " 4 Hello, bob.\n",
386
+ " 5 Hello, bob.\n",
387
+ " 6 Hello, bob.\n",
388
+ " 7 Hello, bob.\n",
389
+ "```\n",
390
+ "\n",
391
+ "というように何回目かを付け足して表示するように書き換えなさい.\n",
392
+ "\n",
393
+ "ヒント:printfも試してみなさい."
394
+ ]
395
+ },
396
+ {
397
+ "cell_type": "markdown",
398
+ "metadata": {},
399
+ "source": [
400
+ "## 今日の日付\n",
401
+ "\n",
402
+ "> require 'date'\n",
403
+ "\n",
404
+ "してから今日の日付表示させなさい.formatも,含めて,たとえば,\n",
405
+ "\n",
406
+ "```bash\n",
407
+ "Hello, bob!\n",
408
+ "2017年 09月 04日\n",
409
+ "```\n",
410
+ "と返すようにしなさい.どうやるかはネットで調べよ."
411
+ ]
412
+ },
413
+ {
414
+ "cell_type": "code",
415
+ "execution_count": null,
416
+ "metadata": {
417
+ "collapsed": true
418
+ },
419
+ "outputs": [],
420
+ "source": []
421
+ }
422
+ ],
423
+ "metadata": {
424
+ "kernelspec": {
425
+ "display_name": "Ruby 2.2.2",
426
+ "language": "ruby",
427
+ "name": "ruby"
428
+ },
429
+ "language_info": {
430
+ "file_extension": ".rb",
431
+ "mimetype": "application/x-ruby",
432
+ "name": "ruby",
433
+ "version": "2.2.2"
434
+ },
435
+ "latex_envs": {
436
+ "LaTeX_envs_menu_present": true,
437
+ "autocomplete": true,
438
+ "bibliofile": "biblio.bib",
439
+ "cite_by": "apalike",
440
+ "current_citInitial": 1,
441
+ "eqLabelWithNumbers": true,
442
+ "eqNumInitial": 1,
443
+ "hotkeys": {
444
+ "equation": "Ctrl-E",
445
+ "itemize": "Ctrl-I"
446
+ },
447
+ "labels_anchors": false,
448
+ "latex_user_defs": false,
449
+ "report_style_numbering": false,
450
+ "user_envs_cfg": false
451
+ },
452
+ "toc": {
453
+ "colors": {
454
+ "hover_highlight": "#DAA520",
455
+ "navigate_num": "#000000",
456
+ "navigate_text": "#333333",
457
+ "running_highlight": "#FF0000",
458
+ "selected_highlight": "#FFD700",
459
+ "sidebar_border": "#EEEEEE",
460
+ "wrapper_background": "#FFFFFF"
461
+ },
462
+ "moveMenuLeft": true,
463
+ "nav_menu": {
464
+ "height": "12px",
465
+ "width": "252px"
466
+ },
467
+ "navigate_menu": true,
468
+ "number_sections": true,
469
+ "sideBar": true,
470
+ "threshold": 4,
471
+ "toc_cell": true,
472
+ "toc_section_display": "block",
473
+ "toc_window_display": true,
474
+ "widenNotebook": false
475
+ }
476
+ },
477
+ "nbformat": 4,
478
+ "nbformat_minor": 2
479
+ }