Why ruby

  • 41 views
Uploaded on

Slides for my Ruby landscape talk at Pretoria.rb - http://www.meetup.com/pretoria-rb/events/186593022

Slides for my Ruby landscape talk at Pretoria.rb - http://www.meetup.com/pretoria-rb/events/186593022

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
41
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
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

Transcript

  • 1. puts "Hello PTA!" # Why Ruby?
  • 2. whoami = { name: "Kenneth Kalmer", twitter: "@kennethkalmer", github: "kennethkalmer", blog: "opensourcery.co.za" } !
  • 3. class History def when? 1995 end def where? "Japan" end def by? "Matz" end end !
  • 4. [1] pry(main)> class History [1] pry(main)* [1] pry(main)* def when? [1] pry(main)* 1995 [1] pry(main)* end [1] pry(main)* [1] pry(main)* def where? [1] pry(main)* "Japan" [1] pry(main)* end [1] pry(main)* [1] pry(main)* def by? [1] pry(main)* "Matz" [1] pry(main)* end [1] pry(main)* [1] pry(main)* end => :by? [2] pry(main)> lesson = History.new => #<History:0x007fcdb306a3f0> [3] pry(main)> lesson.when? => 1995 [4] pry(main)> lesson.where? => "Japan" [5] pry(main)> lesson.by? => "Matz"
  • 5. $ gem install pry Fetching: pry-0.10.0.gem (100%) Successfully installed pry-0.10.0 1 gem installed ! $ pry [1] pry(main)> 1 + 1 => 2
  • 6. $ pry [1] pry(main)> 1.is_a?( Object ) && 1.is_a?( Fixnum ) => true ! [2] pry(main)> true.is_a?( Object ) && true.is_a?( TrueClass ) => true ! [3] pry(main)> nil.is_a?( Object ) && nil.is_a?( NilClass ) => true ! [4] pry(main)> "PTA".is_a?( Object ) && "PTA".is_a?( String ) => true
  • 7. $ pry [1] pry(main)> 1.object_id == 1.object_id => true ! [2] pry(main)> "PTA".object_id == "PTA".object_id => false
  • 8. $ pry [1] pry(main)> require 'nokogiri' => true ! [2] pry(main)> require 'open-uri' => true ! [3] pry(main)> doc = Nokogiri::HTML(open("http://en.wikipedia.org/wiki/ Ruby_(programming_language)")) => #(Document:0x3fe11d253454…) ! [4] pry(main)> paragraph = doc.search('//*[@id="mw-content-text"]/p[23]').text => "Matsumoto has said that Ruby is designed for…” ! [5] pry(main)> paragraph =~ /"([^"]*)/ => 194 ! [6] pry(main)> $1 => "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. That is the primary purpose of Ruby language."
  • 9. The Main Runtimes
  • 10. The Interesting Runtimes
  • 11. The Mobile Runtimes
  • 12. required “reading” http://mislav.uniqpath.com/poignant-guide/
  • 13. 3,239,798,210 downloads of 77,207 gems cut since July 2009
  • 14. require “*” • State of the art dependency management • Authors now building the same tool for the Rust programming language
  • 15. require “sinatra” get "/" do "<h1>Hello PTA</h1>" end • Rack • Sinatra • Padrino • Rails
  • 16. require “adhearsion” class MyController < Adhearsion::CallController def run answer resp = ask "How many woodchucks?", :limit => 1 say "You said #{resp}. That's obviously wrong!" end end ! # adhearsion.com
  • 17. require “artoo” connection :sphero, adaptor: :sphero, port: '4560' device :sphero, driver: :sphero ! work do every(3.seconds) do puts "Rolling..." sphero.roll 60, rand(360) end end ! # artoo.io
  • 18. require “relevance”
  • 19. Tools of the trade
  • 20. require “simple_form” simple_form_for @user do |f| = f.input :email = f.input :password = f.submit "Login" • Rapid form building • Highlight errors • Wrappers for Bootstrap
  • 21. require “better_errors”
  • 22. require “reform” class SongForm < Reform::Form property :title property :length ! validates :title, presence: true validates :length, numericality: true end ! class SongsController def new @form = SongForm.new(Song.new) end
  • 23. require “active_interaction” • Model business processes as simple objects. • Avoid the callback hell that so easily happens in models
  • 24. http://iwanttolearnruby.com/
  • 25. trap("TERM") do puts "WIN" end ! exit