{ "cells": [ { "cell_type": "markdown", "metadata": { "toc": "true" }, "source": [ "# Table of Contents\n", "

1  テキスト
2  配列(Array)
2.1  size
2.2  each
3  ハッシュ(hash)
3.1  シンボル
3.2  操作
3.3  each - key, val
4  正規表現(Regular expression)
5  CLI(Command Line Interface)c4
6  課題
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# テキスト\n", "\n", "* [たのしいruby c3-4](TanoshiiRuby_v5_c2-3.pdf)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 配列(Array)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[\"小林\", \"林\", \"高野\", \"森岡\"]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names = ['小林', '林', '高野', '森岡']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## size\n", "## each" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "小林\n", "林\n", "高野\n", "森岡\n" ] }, { "data": { "text/plain": [ "[\"小林\", \"林\", \"高野\", \"森岡\"]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# each_name.rb\n", "names = ['小林', '林', '高野', '森岡']\n", "names.each{|name|\n", " puts name\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# ハッシュ(hash)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## シンボル\n", "## 操作\n", "## each - key, val" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 正規表現(Regular expression)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "# CLI(Command Line Interface)c4\n", "\n", "* /Users/bob/Github/TeamNishitani/ruby_novice/docs/happy_ruby\n", "* grepもどきの作成" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 課題" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "これをclassにすると以下のとおり.\n", "```ruby\n", "class Hello\n", " def hello(name=\"Ruby\")\n", " return \"Hello, #{name}.\"\n", " end\n", "end\n", "```\n", "さらにrspecを付け足すと,\n", "```ruby\n", "describe Hello do\n", " it 'should return greeting' do\n", " text = 'Hello, Ruby!'\n", " hello = Hello.new\n", " expect(hello.hello).to eq text\n", " end\n", "end\n", "```\n", "\n", "となる.rspecまで考えるとprintをmethod内でしちゃうのではなく,returnして欲しいよね.\n", "```bash\n", "rspec hello_name_spec.rb Mon Sep 4 17:07:29 2017\n", "\n", "Hello\n", " should return greeting\n", "\n", "Finished in 0.0011 seconds (files took 0.16208 seconds to load)\n", "1 example, 0 failures\n", "\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Ruby 2.2.2", "language": "ruby", "name": "ruby" }, "language_info": { "file_extension": ".rb", "mimetype": "application/x-ruby", "name": "ruby", "version": "2.2.2" }, "latex_envs": { "LaTeX_envs_menu_present": true, "autocomplete": true, "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": { "equation": "Ctrl-E", "itemize": "Ctrl-I" }, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false }, "toc": { "colors": { "hover_highlight": "#DAA520", "navigate_num": "#000000", "navigate_text": "#333333", "running_highlight": "#FF0000", "selected_highlight": "#FFD700", "sidebar_border": "#EEEEEE", "wrapper_background": "#FFFFFF" }, "moveMenuLeft": true, "nav_menu": { "height": "84px", "width": "252px" }, "navigate_menu": true, "number_sections": true, "sideBar": true, "threshold": 4, "toc_cell": true, "toc_section_display": "block", "toc_window_display": true, "widenNotebook": false } }, "nbformat": 4, "nbformat_minor": 2 }