- デザインパターンを知るキッカケになりそう
- デザインパターンは知識的に理解しているつもりだが、実践できていない
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby 01.rb | |
user system total real | |
0.880000 0.000000 0.880000 ( 0.884170) | |
0.880000 0.000000 0.880000 ( 0.888569) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 [02/Sep/2016:13:38:35 | |
1 [02/Sep/2016:13:38:36 | |
1 [02/Sep/2016:13:38:37 | |
1 [02/Sep/2016:13:38:38 | |
8 [02/Sep/2016:13:38:49 | |
11 [02/Sep/2016:13:38:50 | |
11 [02/Sep/2016:13:38:51 | |
9 [02/Sep/2016:13:38:52 | |
10 [02/Sep/2016:13:38:53 | |
11 [02/Sep/2016:13:38:54 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -ne 1 ]; then | |
echo "usage: $ yomikata git" | |
exit 1 | |
fi | |
curl http://yomikata.org/word/$1 2>/dev/null| egrep -o "「([^「]+)」です" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test(){ // 関数 | |
console.log("test"); | |
} | |
function Animal(type, voice){ // コンストラクタ | |
this.type = type; | |
this.bark = function(){ // メソッド | |
console.log(voice); | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Singleton パターンを用いると、そのクラスのインスタンスが1つしか生成されないことを保証することができる。 ロケールやLook&Feelなど、絶対にアプリケーション全体で統一しなければならない仕組みの実装に使用される |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
関心事、関連、利害関係 など |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "open-uri" | |
class Titles | |
include Enumerable | |
def initialize | |
@urls = [] | |
end | |
def <<(url) | |
@urls << url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ファイルを生成して、upload するという流れ | |
class FileUploader # Client | |
def initialize(factory) | |
@file_maker = factory.file_maker | |
@uploader = factory.uploader | |
end | |
def make_flie(items) | |
@file = file_maker.make(item) | |
end |
NewerOlder