Skip navigation

Category Archives: Ruby

# Ruby - Rails - Tracing Call to Know Multiple Trigger-call
class Model

  before_update :show_changed_fields

  def show_changed_fields
    p '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    p Model.columns.map(&:name).select{|v|self.send("#{v}_changed?".to_sym) }
    p caller.select{|x|/\/app\//=~x}.collect{|x|x.split('/')[-1]}
  end

end

Remember the old days when I ran Ruby 1.8.2 only, I got similar message from Ruby 1.9.0 (ruby-1.9.0-20060415-i386-mswin32.zip)

"C:\Ruby1.9\bin>irb
C:\Ruby1.9\bin\ruby: no such file to load -- ubygems (LoadError)

C:\Ruby1.9\bin>"

This the result from the last installation from Ruby 1.8.6, since the Distribution for Ruby 1.9.0 Does not include rubygems, so you must remove the Environment Variables that Ruby will lookup for the options.

RUBYOPT = -rubygems

I am waiting my friend install Oracle 10g on our Development Server in SLES 10, so I grab my intermediate file of my Ruby Doc Browser and Compare it with the Ruby 1.9, and this is the result (screen-shoot) in my Open Office

Ruby Diff 1.8.6 to 1.9.0 Kernel
Read More »

My Current editor for webdevelopment (check on Categories on this post)
NOTEPAD++
notepad.png

Is it Ruby-way ala coding…

def terbilang(angka)
satuan = [”] + %w{satu dua tiga empat lima enam tujuh delapan sembilan sepuluh sebelas}.collect{|x|x+’ ‘}
triple = [[‘puluh’,10,20,100],[‘ratus’,100,200,1000],[‘ribu’,1000,2000,1000000],[‘juta’,1000000,1000000,1000000000],[‘milyar’,1000000000,1000000000,1000000000000]]
hasil = satuan[angka] if angka<12
hasil = terbilang(angka.divmod(10)[1]) +’belas ‘ if angka>=12 and angka<20
hasil = ‘seratus ‘+terbilang(angka-100) if angka>=100 and angka<200
hasil = ‘seribu ‘ +terbilang(angka-1000) if angka>=1000 and angka<2000
triple.each{|x|hasil=terbilang(angka.divmod(x[1])[0])+x[0]+’ ‘+terbilang(angka.divmod(x[1])[1]) if angka>=x[2] and angka<x[3]}
hasil
end

Update ruby.doc.browser, this is the screen shoot…
arrayc.jpg
Read More »

my development in ruby using editor that not have auto complete or intelisense, so when i need to know some of the methods is little bit difficult, I am not bother with it but after I have read discussion in our ruby mailling-list, Iam sure not only me have trouble like this , so after digging the ruby quiz, i got simple browser to check methods object of the core / lib / module.scshoot.gif

this is html file and it contains 415 files, pretty big huh, this file can be browse using index / content and iframe. or pick the html file with classname on it.

anyway this not ready but for my need it ok.

*Update
you can download this file in rubyforge.org/rubydocbrowser