Your SlideShare is downloading. ×
0
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
Ruby: Beyond the Basics
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

Ruby: Beyond the Basics

416

Published on

You've learned to program in Ruby, but now you want to start learning about how to move beyond the language basics and make use of some of the dynamic parts of the Ruby language. We'll cover that a …

You've learned to program in Ruby, but now you want to start learning about how to move beyond the language basics and make use of some of the dynamic parts of the Ruby language. We'll cover that a bit here.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
416
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
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
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Ruby: Beyond the Basics by Michael Koby http://www.codecasts.tv
    • 2. Hi, my name is... Michael Koby
    • 3. @mkoby
    • 4. http://www.codecasts.tv
    • 5. http://www.mkoby.com
    • 6. What
    • 7. What• Open Classes
    • 8. What• Open Classes• Dynamic Methods
    • 9. Metaprogramming Ruby by Paolo PerrottaO’Reilly: http://obyk.us/39267Amazon: http://obyk.us/1efe7
    • 10. Open Classes
    • 11. What is an “Open Class?”
    • 12. You’ve Heard of this byAnother Name
    • 13. Monkeypatching
    • 14. class String #shortened for brevity def sub(a, b) #replaces string ‘a’ with string ‘b’ end def gsub(a, b) #similar to sub but with the /g from RegEx end #shortened for brevityend
    • 15. class String def to_alphanumeric gsub /[^ws]/, ‘’ endend
    • 16. 1.9.3 :005 > “my string”.methods.grep /alphanumeric/
    • 17. => [:to_alphanumeric]
    • 18. class Employee def salary “Some Number” endend
    • 19. class Employee def salary “Some Number” endendclass Employee def name “Some Name” endend
    • 20. e = Employee.new
    • 21. e = Employee.newe.salary
    • 22. e = Employee.newe.salary # => “Some Number”
    • 23. e = Employee.newe.salary # => “Some Number”e.name
    • 24. e = Employee.newe.salary # => “Some Number”e.name # => “Some Name”
    • 25. class Employee def salary “Some Number” endendclass Employee def name “Some Name” endend
    • 26. Some Real Life Samples
    • 27. Dynamic Methods
    • 28. How You Usually Call Methods
    • 29. someObject.methodName
    • 30. Dynamically Calling Methods
    • 31. x = 2
    • 32. x = 2x.send(:+, 2)
    • 33. x = 2x.send(:+, 2) => 4
    • 34. class APIRequestWrapper attr_accessor :client def initialize @client = Savon::Client.new do |wsdl| #wsdl.options go here end end ## Makes API request, request_name is string ## parameters is a Ruby hash def make_api_request(request_name, paramenters) @client.request(request_name.to_sym) do |soap| soap.body = parameters end endend
    • 35. Some Real Life Samples
    • 36. In Closing...
    • 37. Open Classes
    • 38. class Employee def salary “Some Number” endendclass Employee def name “Some Name” endend
    • 39. Dynamic Methods
    • 40. x = 2x.send(:+, 2) => 4
    • 41. Metaprogramming Ruby by Paolo PerrottaO’Reilly: http://obyk.us/39267Amazon: http://obyk.us/1efe7
    • 42. Thank You!

    ×