More Related Content
Similar to Ruby, Ruby, Ruby! (20)
More from fg.informatik Universität Basel (17)
Ruby, Ruby, Ruby!
- 3. Übersicht
Ruby
Merkmale
Geschichte
Appetizers
Gems
IDEs
- 5. Übersicht
Rails
Merkmale
Geschichte
Beispiel
- 8. Merkmale
Vollständig objektorientiert
Multiparadigmatisch
Principle of Least Surprise
Irb: interactive ruby
Einflüsse aus: Perl, Smalltalk, Python
- 9. Merkmale
Ruby Core Classes:
String, Array, Hash, Symbol, ...
Fixnum, Bignum, ...
- 11. Geschichte
Yukihiro “Matz” Matsumoto
1993 angefangen
Erste Version 1995
“Ruby” als Anspielung auf Perl
Version: 1.8/1.9
CRuby und JRuby
- 21. class Klasse
def nummer=(Argument)
@nummer = Argument
end
def nummer
return @nummer
end
def +(Objekt)
return @nummer + Objekt.nummer
end
end
- 24. hash = ["key" => "value", "key2" => "value2"]
hash2 = [:key => "value", :key2 => 2]
hash["key"] # -> "value"
hash2[:key2] # -> 2
- 26. module Leet
def give_me_the_answer
42
end
end
class Array
include Leet
end
[1].give_me_the_answer # -> 42
- 28. Ruby Gems
Ruby “Paketmanager”
Bibliotheken dazu installieren
Vergleichbar mit Java Paketen
Mehrere Versionen parallel
- 29. Ruby Gems
Rails ist auch ein gem
(sudo) gem install rails
Beispiele: ImageMagick, thinking_sphinx,
prawn
- 31. IDEs
Eclipse
(Aptana RadRails)
Netbeans
- 33. require 'Qt4'
app = Qt::Application.new(ARGV)
hello = Qt::PushButton.new('Hello World!')
hello.resize(100, 30)
hello.show()
app.exec()
- 34. require 'Qt4'
app = Qt::Application.new(ARGV)
hello = Qt::PushButton.new('Hello World!')
hello.resize(100, 30)
hello.show()
Qt::Object.connect(hello,
SIGNAL('clicked()'), app, SLOT('quit()'))
app.exec()
- 35. require 'Qt4'
class MyWidget < Qt::Widget
def initialize()
super()
quit = Qt::PushButton.new('Quit')
lcd = Qt::LCDNumber.new(2)
slider = Qt::Slider.new(Qt::Horizontal)
slider.setRange(0, 99)
slider.setValue(0)
connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()'))
connect(slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)'))
layout = Qt::VBoxLayout.new()
layout.addWidget(quit)
layout.addWidget(lcd)
layout.addWidget(slider)
setLayout(layout)
end
end
app = Qt::Application.new(ARGV)
widget = MyWidget.new()
widget.show()
app.exec()
- 39. Merkmale
Don't Repeat Yourself
Convention Over Configuration
Model-View-Controller
- 40. Merkmale
ActiveSupport: Helfermethoden
ActiveRecord: Datenbanken
ActionPack: ActionController / ActionView
Auch unabhängig von Rails verwendbar