Blogs

Hi all, I just want to share about an IDE that already replaced the RadRails for Ruby on Rails IDE, i.e. Aptana. I use this new kind of IDE to create static HTML/XHTML, CSS, JavaScript, Ruby on Rails. This is a greate IDE. I think some of you already use this too. OK..we have to migrate to Aptana.. not RadRails again!

Hi all, I really sorry 'cause I never write at this blog for very long time :D. I want to try to start it again with a small share information. This article is very interested me to figure out about how to programming it with Ruby. Sorry if this blog just like a bookmark.

Creating Games in Ruby

May be we can try to make ruby as our base language programming.

Who knows the fanatastic technology called commet?
Commet is the final weapon to our website much more interactive!!
Of course, you know Lingr!! Very Amazing web service.
Don't you want to develop the web site like Lingr with commet technology??
Here is your fire starter :)
At very first, we should install one plugin which is called "Shooting star!!"
This plugin makes your rails application fly up to the star and your request to the web server directly reflects to the reader of your web application.
OK, that's enough to enlight.
Start the very small tutorial. This tutorial makes your appilcation commet :)

  1. #1: First of all, create your own project
  2. $ rails real_chat
  3. #2: Second, install the shooting star plugin with gem command
  4. $ gem install shooting_star
  5. #3: change the direction
  6. $ cd real_chat
  7. #4: initialize the shooting star, this command reacts nothing but don't worry :)
  8. $ shooting_star init
  9. #5: generate the bottom technology of commet with the generator given by shooting star
  10. $ ruby script/generate meteor
  11. #6: Also you can get the chat scaffold type the following command
  12. $ ruby script/generate chat
  13. #7: Launch your web server!!
  14. $ ruby script/server
  15. #8: Shooting star also needs to be launched
  16. $ shooting_star start

OK that's all, now time to call your buddy and try the application
http://localhost:3000/chat is your brand new comet application.
there is no Ruby code... Agile!! Be agile!! Hahaha!!
Time talk today's dinner dynamically with this application :)

I hope you enjoy the tutorial!!
Thanks a lot :)

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.

  1. def method_missing( id, *args )
  2. if self[id].nil?
  3. m = id.to_s
  4. if /=$/ =~ m
  5. self[m.chomp!] = (args.length < 2 ? args[0] : args)
  6. else
  7. self[m]
  8. end
  9. else
  10. self[id]
  11. end
  12. end
  13. h = { "foo" => "bar",:blah => "thinkruby"}
  14. h.blah # => thinkruby
  15. h.foo # => bar

It's not bad,right?

Hi all devils!!
How are you.
Yas is reactivated finally :)

Today I tried some tricky situation.

I needed to compact second dimensional array, which includes some id's and other elements.

Using id and detect the target elements and remove them.
Oh my English is getting worse day by day...
But I believe code talks everything instead of me :)
Ok today's small piece of Ruby code is following

  1. #Compact the second demencional array
  2. arr = [[0,"miyake","password"],[1,"miyake","hoge"],[2,"hoge","hoge"]]
  3. @target = 0
  4. arr.each {|a|
  5. if a[0] == @target
  6. arr[@target] = nil
  7. end
  8. }
  9. p arr.compact

Enjoy if you have some comment or any more great idea!!
Please share with us! Thanks from Japan!

Syndicate content