discovering ruby. welcome to barcamp ireland!. i’m going to talk through my early days with ruby....

16
Discovering Ruby. Welcome to Barcamp Ireland!

Upload: antony-young

Post on 27-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Discovering Ruby.Welcome to Barcamp Ireland!

I’m going to talk through my early days with ruby.

I’m trying to build a ruby applications so what I know is based off that.

But I’m not with ruby that long either so if I look blankly at you, prompt me about where to ask.

So what are you talking about?

http://poignantguide.net/ruby/chapter-2.html

So where do you go to first?

http://tryruby.hobix.com/

Whats the coolest thing you learn there?

www.ruby-lang.org/

The recently redesigned ruby homepage.

Good for downloading ruby, updates, finding links and the ruby reference library.

Bad for finding unusual but good ruby sources.

Bad for finding simple ruby examples.

Other Resources to look at.

Ruby Garden. www.rubygarden.org/

Ruby core librarywww.ruby-doc.org/core/

Ruby standard librarywww.ruby-doc.org/stdlib/

Ruby User guide.

Again we are looking at the very basics.No ties to the standard library. So you cant see a follow through.Hard to tell without running the code if the code is up to date.Out of date code is a big problem when you are error checking.

So you want to make a ruby application?

So how can you?

Besides using ruby-on-rails.

Pikeaxe says ruby-tk.

So that’s what I went with..

However Ruby-tk is poorly documented.

QT is considered better documented and prettier.

QT Verses Ruby-TkAnd don’t you partly use ruby for the prettiness.

So finding out ruby-tk is not pretty is upsetting.

QT is dual licensed. A commerical license and a GPL.

But I went with Ruby-tk so I cant help you with QT.

http://poignantguide.net/ruby/chapter-2.html

http://pub.cozmixng.org/~the-rwiki/?

Useful due to lots of examples.

Unfortunately in japanese.

Unfortunately some of the code is out of date.

Still probally one of the best ruby-tk references.

Some simple ruby-tk code.Button packing.

require "tk"

TkLabel.new { text "Top" pack('side' => 'top') } TkLabel.new { text "Middle" pack('side' => 'top') } TkLabel.new { text "Bottom" pack('side' => 'top') }

Tk.mainloop

Ruby and Mysql

So you need a database.For mysql you have two modules to choose from.Confused?Thought this was newbie-friendly?Well Ruby gems will help you install whichever one you pick.

Ruby Gems

http://rubyforge.org/projects/rubygems/

Ruby gems helps you install add-ons to ruby.

It tries to make life easier.

However you will have to reinstall your gems every time you upgrade ruby.

Mysql ruby test code from Kitebird.

You will know this test.Simple.rb 

require “mysql”

   begin       #this example is used for checking if your installation is correct.       # connect to the MySQL server       dbh = Mysql.real_connect(”localhost”, “testuser”, “testpass”, “test”)       # get server version string and display it       puts “Server version: ” + dbh.get_server_info         rescue MysqlError => e       print “Error code: “, e.errno, “\n”       print “Error message: “, e.error, “\n”   ensure

       # disconnect from server

       dbh.close   end

So you have the means

You have your database, ruby can connect to the database. You have picked your gui method.You think you can make one.What now?

http://poignantguide.net/ruby/chapter-2.html

Any questions?

hook C:/ruby/rubygems-0.9.0/ ./post-install.rb failed:undefined method 'post_install_message' for #<Gem::Specification:0X3337fa8>

Error messages!