Your SlideShare is downloading. ×
0
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Open Academy - Ruby
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Open Academy - Ruby

374

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
374
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. RubyBudapest - 7th June, 2012 Papp László nucc @ t witter
  • 2. The first met... blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 3. Yukihiro Matsumoto (matz) blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 4. "I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python. Thats why I decided to design my own language." blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 5. R ecipe 120g Lisp 100g Perl 130g P ython g Sm alltalk 120 blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 6. Interpreted Dynamic typed Strong in meta-programming blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 7. blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 8. Ruby blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 9. “Trying to make Ruby natural, not simple” blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 10. “Ruby is simple in appearance, but is very complex inside, just like our human body” blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 11. People.say(“Hello OpenAcademy!”) blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 12. People.say “Hello OpenAcademy!” blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 13. trash << file if file.rubbish? blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 14. trash << file unless file.referenced? blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 15. i f trash << file unless file.referenced? o t blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 16. :Symbol blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 17. prezi = { :title => “Ruby”, :date => “07/06/12” } blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 18. Academy.new :location => “BME” blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 19. Academy.new({:location => “BME”}) blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 20. (1..100).select do |i| return i % 2 == 0 end => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100] blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 21. (1..100).select do |i| i % 2 == 0 end => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100] blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 22. (1..100).select {|i| i % 2 == 0} blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 23. def repeat(x, &block) (1..x).each do |i| yield(i) end end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 24. def repeat(x, &block) (1..x).each do |i| yield(i) end end repeat 10 do puts “Hello Academy!” end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 25. def repeat(x, &block) (1..x).each do |i| yield(i) end end repeat 10 do |iteration| puts “#{iteration}. Hello Academy!” end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 26. blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 27. Everything is an object! Really! blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 28. 1 blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 29. 1.even? => false blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 30. 5.times do puts “I will never use PERL!” end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 31. 1.nil? => false blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 32. nil blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 33. nil.nil? => true blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 34. openAcademy = Class.new thisAcademy = openAcademy.new blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 35. class OpenAcademy def initialize(year, month) @year = year @month = month end end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 36. class OpenAcademy attr :year def initialize(year, month) @year = year @month = month end end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 37. class OpenAcademy attr :year end def year @year end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 38. class OpenAcademy attr_accessor :year end def year @year end def year=(value) @year = value end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 39. class OpenAcademy attr_accessor :year end academy = OpenAcademy.new(2011, 06) academy.year = 2012 puts academy.year => 2012 blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 40. class OpenAcademy attr_accessor :year def year=(y) @year = y.to_s end end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 41. class OpenAcademy attr_accessor :year def year=(y) @year = y.to_s end academy = OpenAcademy.new(2011, 06) end academy.year = 2012 puts academy.year => “2012” blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 42. class Academy < Conference end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 43. module Comperable # mixin end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 44. class Academy < Conference include Comperable def <=>(o) myval = self.year.to_s + self.month.to_s other = o.year.to_s + o.month.to_s myval <=> other end end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 45. class Academy < Conference include Comperable def <=>(o) myval = self.year.to_s + self.month.to_s other = o.year.to_s + o.month.to_s myval <=> other end end this_academy = Academy.new(2012, 6) last_academy = Academy.new(2011, 10) last_academy < this_academy => true blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 46. blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 47. Advanced Level blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 48. 2.prim? blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 49. class Fixnum def prim? 2.upto(to_i/2).each do |i| return false if to_i % i == 0 end to_i > 1 endend blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 50. class Fixnum def prim? 2.upto(to_i/2).each do |i| return false if to_i % i == 0 end to_i > 1 end 2.prim? => trueend 1.prim? => false blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 51. class << my_object def prim? ... end end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 52. academy = Mock.new academy.stubs(:year).returns(2012) academy.stubs(:month).returns(6) blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 53. academy = Mock.new academy.stubs(:year).returns(2012) academy.stubs(:month).returns(6) print academy.month => 6 # Test confererence registration Conferences.register academy blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 54. class Xml def method_missing(method, *args, &block) print "<#{method}>" yield if block print "</#{method}>" end end doc = Xml.new doc.head { doc.title { print “Academy } } => <head><title>Academy</title></head> blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 55. class User %w(name email password).each do |method| define_method(method) do @data[method.to_sym] end end end blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 56. object.methods object.respond_to? :method alias :from, :to class_eval module_eval Module.included(base) ... blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 57. Dave Thomas - Programming Ruby blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc
  • 58. ? twitter.com/nucc blog.bteam.huOpen Academy - June 7, 2012 twitter.com/nucc

×