class A
def foo
[1, 2, 3]
end
end
class B < A
def foo
super.map{ |n| n * 2 }
end
end
puts A.new.foo.to_s
puts B.new.foo.to_s
Output
[1, 2, 3]
[2, 4, 6]
class A
def foo
[1, 2, 3]
end
end
class B < A
def foo
super.map{ |n| n * 2 }
end
end
puts A.new.foo.to_s
puts B.new.foo.to_s
Output
[1, 2, 3]
[2, 4, 6]
As root execute:
apt-get update
apt-get install build-essential ruby rails rubygems1.8
apt-get install ruby1.8-dev libopenssl-ruby
Chance PATH at /etc/environment:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/lib/gems/1.8/bin"
Update your current environment:
source /etc/environment
Install the Heroku gem:
sudo gem install heroku
Run Heroku authentication configuration:
heroku auth:login
Enter the credentials for your Heroku account.
Done!
O Netbeans.org anunciou a disponibilidade do NetBeans IDE 6.5 Beta. Abaixo a tradução do anúncio:
O NetBeans IDE 6.5 introduz várias novas funcionalidades, incluindo uma IDE robusta para PHP, deputação de JavaScript para o Firefox e IE, e suporte a Groovy e Grails. Esse lançamento também inclui várias melhorias para o desenvolvimento em Java, Ruby e Rails, e C/C++. Dentre as melhorias no Java destacam-se: suporte nativo ao Hibernate, importação de projetos do Eclipse, e compilação no salvamento.
Links:
Outros destaques:
O NetBeans IDE 6.5 final está planejado para ser lançado em Outubro de 2008. Como sempre, é bem vindo e nós encorajamos seu feedback sobre sua experiência usando a IDE NetBeans. Visite nossas listas de email ou faça uma postagem no seu blog.
A really cool piece of code I read today in the book Ruby on Rails: Up and Running.
class Talker
def method_missing(method)
if method.to_s =~ /say_/
puts $'
end
end
end
t = Talker.new
t.say_hello
t.say_something
t.say_goodbye
And running
$ ruby Talker.rb
hello
something
goodbye
But why do that when we have parameters? Because you can do some methods really dynamic with a clear semantic, just looking for them you know are they are doing.
JRuby is a Java implementation of the Ruby interpreter, with an tightly integrated with Java. In this examples you will call swing components.
On Ubuntu you can get it installing the package jruby (a meta package for jruby1.0 or jruby0.9 packages).
To test it save this code as test.rb and invocate it with the jruby interpreter:
require 'java' frame = javax.swing.JFrame.new() frame.getContentPane().add(javax.swing.JLabel.new('Hello, JRuby World!')) frame.setDefaultCloseOperation(javax.swing.JFrame::EXIT_ON_CLOSE) frame.pack() frame.set_visible(true)
$ jruby1.0 test.rb
ps: We did not define a close method, so to close this windows you’ll need to kill its process or press Ctrl+C in your terminal.
Creative Commons image from Flickr.
From days 15 to 20 from April, I’ll be in Porto Alegre. I’ll participate on FISL (an old dream) with the presentation “Netbeans: beyond Java”. I’d like to talk about how you can use Netbeans as a great IDE for languages others than Java like Ruby, PHP, JavaFX, Javascript, Python, etc.
Probably I’ll be able to participate also on two events before FISL (about Opensolaris and Java ME). 🙂
So … how chimarrão tastes?
More books to my shelf.
First I’ll take a look … JavaFX, of course. 🙂
ps: The JavaFX book I win as a prize for naming the SDN Channel podcast, CampusCast. Thanks Edu that bring it to me from USA. 😉