- 61 名前:デフォルトの名無しさん mailto:sage [2009/12/08(火) 14:02:01 ]
- >>54
class Publisher def initialize(p) @text, @from, @to, @path = p[:text], p[:from], p[:to], p[:path] end def publish output = replace(@text, @from, @to) save(output, @path) end def replace(text, from, to); text.gsub(/#{from}/){to}; end def save(str, path); File.open(path, 'wb'){|f| f.print(str)}; end end # Publisher.new(:text => 'ruby大好き!', :from => 'ruby', :to => 'オブジェクト指向スクリプト言語Ruby', # :path=> 'ruby_love.txt').publish #=> "オブジェクト指向スクリプト言語Ruby大好き!" これの Publisher#save をテストしたいとかそんなの?
|

|