quattro_4 scribble

scribble 落書き (調べた事をただ落書きする)

RubyTapas

RubyTapas #076 - #078

076 Tail Part 5: Idiom ? do whileっぽいループをmethodで書き換え def each_xxx() ... yield(yyy) ... end 077 Tail Part 6: Process As Object ★★ さらにリファクタリング class追加 分かりやすくなった気がする 078 Tail Part 7: Cooperating Objects …

RubyTapas #070 - #075

070 break ? yield, break, ensure 使いどころが分からない 071 break with a Value ★ break name if name =~ /^S/ breakはreturnの値を上書きできる break "<Not Found (Stopped at #{f.lineno}: '#{line.chomp}')>" lineno [ラインノ] 072 Tail Part 1: Random Access ★ unixのtailと同等のものを作る file = op</not>…

RubyTapas #062 - #069

062 Fiber ?? Homemade numerator イミフ 063 Gem-Love Part 3 ? webmock, tdd ムズイ 064 Yield or Enumerate ★ 引数無しだとEnumeratorが返る return to_enum(:names) if block_given? return to_enum(__callee__) if block_given? 065 PulseFFI Part 7…

RubyTapas #058 - #061

058 ARGF ★★ ARGFはあまり使ってないけどARGVよりもっとファイルを受け取ってlineごととか処理を書きやすい print "#{ARGF.path}: #{sekrit(line)}" ファイル名を .path で求められるのは新たに知った 059 Enumerator ★ まずは to_enum Enumeratorは何かすご…

RubyTapas #048, #049, #050, #055, #056

048 Memoize ★★★ おおMemoize 今会社のプロジェクトでまさに改善が必要で取り組んでいるトピックだ ラッキーすぎる 流れが来ている benchmarkの部分 require 'benchmark' puts Benchmark.measure { module Memoizableが思ったよりいろいろやっている ケース…

RubyTapas FFI #026, #047, #051, #054, #057

RubyTapasさぼりがちだ 原因は分かっている。 最新が出たら最新のものをチェック、他の時間で随時古いエピソードをキャッチアップが理想なのだが、 FFI(#026)のエピソードがあって、その後FFI Part 2, 3, 4, 5と週1ぐらいで更新されている。 FFI Part 1をや…

RubyTapas #052 - #053

052 The End of Mocking ★ 'I like to use mock and stub objects to help me drive out a design.' ファイル書き出しひとつとってもこんな書き方があるのかといった感じ あとはspecの中で tmpfile 使えるようになるとよさそう file = Tempfile.open('w') on…

RubyTapas #011 - #015

011 Method and Message ?? 多分もう何回か見てもピンと来ない。理解不能だ。 A message is a name for a responsibility which an object may have. A method is a named, concrete piece of code that encodes one way a responsibility may be fulfille…

RubyTapas #006 - #010

006 Forwardable ★ 同じような委譲のメソッドが多い時にシンプルに書ける class User attr_reader :account def initialize(account) @account = account end def first_name account.first_name end def last_name account.last_name end 次のように書ける …

RubyTapas #039 - #046

やる気が尽きるのも時間の問題かもしれないからできるときにやる 書籍とかも頭から読んで読まなくなる事多々あるので 今日は新しい方をやる 039 Gem Love Part 1 ★ Rubygems plugin basic structure require 'rubygems/command_manager' Gem::CommandManager…

Starting RubyTapas #001 - #005

I have subscribed RailsCasts over 3 years. I have subscribed Ruby5 over 2 years. But I feel I'm not good at clean coding and programming design. (Actually I realize myself improved to use many tools, gems etc for recent years.) I started t…