2007-04-01から1ヶ月間の記事一覧

シンプルなDSL

もう、これでいいや。後は実際に必要になったら使いやすいように検討する方向で。 class Dsl def define(&block) self.instance_eval(&block) end def print_name puts 'my name is hogehoge!\n' end def print_age puts 'i am hogeteen!\n' end end dsl = D…

ターミナルエミュレータ

今までckというターミナルエミュレータを使っていたが、poderosaのほうが使いやすそうなのでしばらくこっち。

インストールメモ

新しいOSにcygwin+rubyをインストールしたので、それ以降のインストールについてメモ。 gem ダウンロード(http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.xxx)&解凍後、 $ ruby setup.rb : : Successfully built RubyGem Name: sources Versi…

class Creature # Get a metaclass for this class def Creature.metaclass class << Creature self end end # Get NG metaclass for this class def Creature.metaclass_ng self end p metaclass p metaclass_ng これの実行結果は… irb(main):001:0> requir…

まずDSLの勉強を…

青木さんのruby添削などでDSLの実装例が載っているが、限りなくシンプルなものを…、ということで以下のサイトを見つけた。後で読みます。読んでみた()。といっても英語はほとんど読んでない。読むの遅いし眠いので。 # The guts of life force within Dwemth…

ファイルアップロード

view <% form_tag({:action => 'update', :id => @memo}, :multipart=> true) do %> <p><label for="memo_image1"><b>image1</b></label><br/> <%= file_field :memo, :image1 %> <%= submit_tag 'Edit' %> <% end %> controller uploaded = params[:memo][:image1] filepath = 'public/images/' + uploaded.o</br/></p>…

migrationで直接SQL

class CreateUploadeds < ActiveRecord::Migration def self.up create_table :uploadeds do |t| t.column :memo_id, :integer t.column :name, :string t.column :path, :string end remove_column :memos, :image1 remove_column :memos, :image2 remove_c…