sign in
Home | Updates | Pages | Users | Admin | Help
Comparing version 2 and version 1 back

h1. 18th Ruby/Rails Meeting – Hirakata

h2. What is Ruby

* Everything is Object.
* Open Class - you can extend every class
* Block - do ... end (or { ... } )
* Useful classes:
** Numeric, String, Symbol, Array, Hash, Regexp, Range

h3. Class and Instance

link_to('',{:page => 2})
link_to '', {:page => 2}
link_to '', :page => 2
h3. Rails * *CoC* (Convention over Configuration) * *DRY* (Don't Repeat Yourself) h3. Sample application - BBS
$ rails -d sqlite3 bbs && cd bbs
$ script/generate model Comment
%% edit app/models/comment.rb
%% edit db/migrate/001_create_comments.rb
$ rake db:migrate
better use _scaffold_resource_ , it will create model, controller and the migration h2. The Ruby "Saho" how to look "beautiful". "busaho" - mazui ;) h3. Basics * object * block * duck typing * metaprogramming h3. "Busaho" * The code is not gentle for the programmer * overloading (in C++ and Java it's usual) * creating classes just for the classes themself (overwork) * just copy-paste from some design patterns * difficult method names * _eval()_ is not the evil, it's the LAST weapon what to use for binary data - _pack()_ and _unpack()_ ? pack library? h2. Game programming with Ruby - MyGame library Dan-san, dGames, http://dgames.jp/dan/ There is a book - "starting game programming with ruby" + CD h3. Concepts * SDL-based (Ruby/SDL)short code (multiplatform) * everything is object (character, blocks, tree, sky etc.) * designed for begginers * to be easy and "tanoshii" ;) h3. Install * SDL * Ruby * Ruby/SDL * MyGame For Windows: ActiveScriptRuby, download and install Ruby/SDL
install_mygame.rb
Other: _mygame-0.9.1.tar.gz_ h3. Usage * Bootstrap - (_require ''_) * Main loop - block (_do..end_), 60 times per sec (60Hz) ** clear screan ** _wait()_ ** create object (render) ** display object * Using _display_ object * Keys ** _key_pressed?()_ ** _new_key_pressed?()_ h3. Sample
require 'mygame/boot'
Image.render 'sample.png', :x => 100, :y => 100
Image.render 'sample.png', :x => 100, :y => 200

image = Image.new('sample.png')
image.x = 50
image.y = 100
image.scale = 2.0
image.angle = 90
image.alpha = 128
image.render

counter = 0
main_loop do
  image.render
  image.x += 1       # moving the object (sliding)
  image.angle += 8   # rotation

  # using keys
  image.x += 8 if key_pressed?(Key::RIGHT)
  image.x -= 8 if key_pressed?(Key::LEFT)
  image.y += 8 if key_pressed?(Key::DOWN)
  image.y -= 8 if key_pressed?(Key::UP)

  counter += 1 if new_key_pressed?(Key::SPACE)
  Font.render(counter)
end
h2. Internationalization in Ruby Ruby-GetText-Package 8 steps in internationalization application -> .pot file -> ja, pl -> .mo # vim config/environment.rb # vim app/controllers/application.rb # vim Rakefile # rake updatepo # (make po files from the .pot file) # rake makemo
require 'gettext/rails'
....
"Ujihisa-san's slides on SlideShare":http://www.slideshare.net/ujihisa/i35s h2. Rails service PatchService - http://www.patchservice.net/
Powered by JunebugWiki v0.0.31