Normally,when ruby is not able to find the method,it usually raises
"NoMethodError: undefined method "methodname"".That's what we always stuck,nothing special.
Above all,because of Ruby is a kind of dynamic language,what it does exactly if it can't find the method is calling "method_missing" method and method_missing raises a NameError exception,what is the point? you're able to apply the method_missing method in your application and do something cool.When we use hash,we normally call hash["key"] or hash[:key].What if we would like to call it something like hash.key.And here is a bit tricky used of it.
def method_missing( id, *args ) if self[id].nil? m = id.to_s if /=$/ =~ m self[m.chomp!] = (args.length < 2 ? args[0] : args) else self[m] end else self[id] end end h = { "foo" => "bar",:blah => "thinkruby"} h.blah # => thinkruby h.foo # => bar
It's not bad,right?
Mostly,we listen audio files in mp3 ,but sometime we have the audio in other formats.Then how to trancoding it to mp3?
And again using powerful ruby library always help us.Like today I'd like to show you guys with
R2mp3 library which intends to convert all audio files on the planet to mp3 with super simple Ruby code and currently support wma,m4a(aac),ra(rm).
Requirement software
(on Ubuntu)
$sudo apt-get install mplayer lame
(on OS X)
$sudo port install mplayer lame
Install the library
$sudo gem install r2mp3
or
$svn checkout http://r2mp3.rubyforge.org/svn/trunk/ r2mp3
Start Coding
require 'rubygems' # if install using gem require 'r2mp3' Converter.new(:convert=>:wma,:file=>"test.wma"){|f| f.to_mp3 }
test.mp3 is already there.Thanks R2mp3.
We don't need to download any fancy gui programs,do we? :)
Here are Ten libraries you must have in the box.
1. Zlib
2. Digest::MD5
3. StringIO
4. Tempfile
5. Readline
6. Find
7. YAML
8. dbm
9. Pathname
10. OptionParser
Fully pointed out by [Doug Beaver]
(It's a bit old article,but it's all great libs)
King raja wakes me up,lol.Though no technical today :)
One superb conference just finished.
RAILSCONF EUROPE 2007
you guys could check all Presentations out.
those cool slides covering areas as wide as Ferret, REST, Adobe Flex, Amazon S3 and JRuby.
while i'm looking forward to watching DHH keynote in downloadable format.(Streaming kills me T_T)
anyone has?
"Web application using Ruby on Rails (not limeted for PC, web application for mobile is also welcome.)
If Ruby on Rails is used for building a web service, there's no limitation to use other softwares and modules."

The competition starts from July 2 to Sep 25.
the first price a new application is 1,000,000 Japanese Yen (about8,300US$) & extra prize are sponsored by DRECOM (I think most guys here ever visited DRECOM ^^).
Check out more detail [here]
GOOD LUCK!!

