Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Saturday, December 23, 2006

TOP 10 RUBY Sites: 2006 Edition

Since we are arrive at the end of this year, this is the final 2006 edition of the “TOP 10 Ruby Sites”, the best ruby sites around the world. I think it’s very useful to start learning ruby.

1. Ruby Lang site
2. The pragmatic programmers book
3. Rails framework site
4. Ruby documentation Project
5. The Ruby page on wikipedia
6. Rails tutorial book
7. Radrails:Great Ruby IDE
8. Ruby Garden
9. The great poignant guide to Ruby
10. Hal Fulton`s Rubyhacker site

This ranking is made by the comments of people and friends who are visiting this blog reguraly, and with the google pagerank of these sites.You can submit your vote by e-mail or by a comment in this page.

Sunday, November 12, 2006

TOP 10 RUBY Sites: November Edition

This is the November 2006 edition of the “TOP 10 Ruby Sites”, the best ruby sites around the world. I think it’s very useful to start learning ruby.

1. Ruby Lang site
2. The pragmatic programmers book
3. Rails framework site
4. Ruby documentation Project
5. The Ruby page on wikipedia
6. Rails tutorial book
7. Radrails:Great Ruby IDE
8. Ruby Garden
9. The great poignant guide to Ruby
10. Hal Fulton`s Rubyhacker site

This ranking is made by the comments of people and friends who are visiting this page reguraly, and with the google pagerank of these sites.You can submit your vote by e-mail or by a comment in this page.

Sunday, October 08, 2006

TOP 10 RUBY Sites : October Edition

This is the October 2006 edition of the “TOP 10 Ruby Sites”, the best ruby sites around the world. I think it’s very useful to start learning ruby.

1. Ruby Lang site
2. The pragmatic programmers book
3. The Ruby page on wikipedia
4. Rails framework site
5. Ruby documentation Project
6. Radrails:Great Ruby IDE
7. Rails tutorial book
8. The great poignant guide to Ruby
9. Victor Rottenstein blog : )
10. Ruby Garden

This ranking is made by the comments of people and friends who are visiting this page reguraly, and with the google pagerank of these sites.You can submit your vote by e-mail or by a comment in this page.

Tuesday, September 05, 2006

TOP 10 RUBY Sites : September Edition

This is the September 2006 edition of the “TOP 10 Ruby Sites”, the best ruby sites around the world. I think it’s very useful to start learning ruby.

1. Ruby Lang site
2. The pragmatic programmers book
3. The great poignant guide to Ruby
4. The Ruby page on wikipedia
5. Rails framework site
6. Rails tutorial book
7. Radrails:Great Ruby IDE
8. Ruby documentation Project
9. Victor Rottenstein blog : )
10. Ruby Garden

This ranking is made by the comments of people and friends who are visiting this page reguraly.You can submit your vote by e-mail or by a comment in this page.

Saturday, August 05, 2006

TOP 10 RUBY SITES: August edition.

This is the August edition of the “TOP 10 Ruby Sites”, the best ruby sites around the world.
I think it’s very useful to start learning ruby.

1. Ruby Lang site

2. The great poignant guide to Ruby

3. The pragmatic programmers book

4. Rails tutorial book

5. The Ruby page on wikipedia

6. Rails framework site

7. Ruby documentation Project

8. Victor Rottenstein blog : )

9. Great IDE

10. Ruby Garden

Wednesday, August 02, 2006

Beginning RubyOnRails: The view layer helpers

One thing I’ve found great in the Rails framework API is that provides a lot of built-in classes and methods to help coding a page, and once you know a little about them, they are very useful.

An example of this is the ActionView::Helpers::DateHelper module, who provides date methods for the presentation layer, its very useful to accelerate the view construction.

One of my favourites is the date_select method that let you create a date combo-style drop down with many options, and it support the disabled property too!



So look at this example:


date_select ('one_object', 'the_method', :disabled => true)

Yep, and now you have a drop down combo box with endless dates in your page!, it really improves programmers coding speed, isnt it?


Tuesday, August 01, 2006

RubyOnRails howto: Create a simple XML view of a persisted object

I like to share with you a simple and easy way to generate an XML output for a persisted object using a layout templete. I’ve found a similar implementation surfing the RubyOnRails site and it works too.
Supose you have a “documents” repository in your relational database and these documents have 3 fields: title, author and a description. What we want to do is to (generate) and show a XML file for every listed object.
So, First you have to add a new file in your application view folder describing your xml desired structure, this file act as the XML templete, I will name it esml.rxml:

xml.instruct! :xml, :version=>"1.0"
xml.instruct! :rss, :version=>"2.0"
xml.document {
xml.title("a",@document.title)
xml.author(@document.author.name)
xml.description(@document.body)
}


Next add a link to your XML document in your default “list” or “show” page (in the View folder of course):

link_to 'XML view of the document', :action => 'esml', :id => document

Then you have to create the action in your application controller .rb file (I have named it “esml”, I know! , I’m not very original…)

def esml
@document = Document.find(params[:id])
render :layout => false
end


Youre done!, that’s all you need to do , now click through the new link, you will find a fresh XML document for every document requested!...yep, is too easy, isn’t it?

Friday, July 28, 2006

Ruby decorator pattern

Is any kind of ruby decorator pattern out-of-the-box there?
so far i didn't find any pure decorator pattern in ruby, instead of this all i have found is the ruby-way of decorating.

(Updated June 2006)
So.. times goes by ... and I found this implementation by Jason Arhart using module.

class Foo
def initialize(s)
@s = s
end
def to_s
@s
end
end

module SingleQuoted
def to_s
"'" + super + "'"
end
end

module DoubleQuoted
def to_s
'"' + super + '"'
end
end

foo = Foo.new('foo')
puts "#{foo.id} - #{foo}"
foo.extend(SingleQuoted)
puts "#{foo.id} - #{foo}"
foo.extend(DoubleQuoted)
puts "#{foo.id} - #{foo}"

Wednesday, July 26, 2006

Ruby Composite Pattern

I have found this intresting implementation of the composite pattern based on the missing_method ruby structure...

class Quelindo
def
method_missing(method_id, *args)
puts "Hee hola, no hay ningun metodo que se llame #{method_id}"
end
end

# implementemos esto para ver como va...
c=Quelindo.new
c.sarasa

class Leaf
def scale(factor)
end

def addChild(kid)
# do nothing or raise an exception
end

def getKid( index)
# do nothing or raise an exception
nil
end
end


class Composite
def initialize
@kids = []
end
def
method_missing(method_id, *args)
@kids.each do kid
kid.send(method_id, *args)
end
end
def addChild( kid)
@kids <<>


# heee bueno esta es la implementacion
c = Composite.new
c.addChild("Hola")
c.addChild(Composite.new)
a = Leaf.new
c.addChild(a)
puts c.getChild(1)

Instalacion de Ruby

Instalacion de Ruby en Windows
Para instalar el lenguaje Ruby + Ruby IDE + Server(Apache+Mysql) en windows

1 - Instalar el lenguaje Ruby (1.8.2) Bajar http://rubyforge.org/frs/download.php/4174/ruby182-15.exe
Ejecutar el exe y listo...
2 - descomprimir en C:\ruby
3 - Instalar el Framework Rails para windows (instantRails)Bajar http://rubyforge.org/frs/download.php/7972/InstantRails-1.0-final-win.zip
4 - Descomprimir, mover carpeta al c:\InstantRails-1.0(Ejecutar el InstantRails.exe para iniciar Apache + MySQL.)( Tener instalado JDK 1.4 En adelante..)
5 - Entrar a : http://prdownloads.sourceforge.net/radrails/radrails-0.5.3-win32.zip?download>>Seleccionar el Mirror y bajar.
6-Extraer el zip
7 - Ejecutar "radrails" en la carpeta destino.

Saturday, July 22, 2006

Friday, July 21, 2006

Ruby for newbies (Part 1) : Encapsulation made easy

You have to keep one important thing in mind before you develop a new class: it’s called Encapsulation.
Why? Well, it’s basically because in order to maintain your object consistency isn’t a good idea to allow the world to access your object instance variables directly. So if you know other programming languages, lets said Java for example, you would have to create your own methods for every attribute you create, getters and setters they said... (Yes you can do it automatically with eclipse or whatever)
Welcome to Ruby, a wonderful world that will let you focus in the solution domain instead on the complicated keywords. So, in this example I will show an Example class and we will ask it to speak one word.

class Person
attr_reader :name

As you can see, we first create this shortcut that will act as our accessor method (getter) to the real instance variable called name (you could add as many as you need!)

def initialize(therealname)
@name=therealname
end
end

Then, we just create the initialize method to setup the real name of our variable, and note the “@” at the beginning, yes that means this is our own instance variable.

puts Person.new("Vic").name

So, we execute our small class , and as we can see, because of the “puts” sentence : ) , we create a new Person, and we call it “Vic”, then we ask to our class (yes, public by default) method, to give us his name,“Vic”. Does anybody know an easy way to do it?


Sunday, July 16, 2006

Enterprise Ruby

Rails isn´t a Ruby Enterprise framework and this idea is cristal water form me. So, for the last 4 weeks I was doing a little research over the net but its seems that in our near future we won´t see any Ruby Enterprise framework or a SOA oriented solution.
Last week Martin fowler has published an intresting article in his blog about this.

Thanks
Vic.