Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Seja Feliz com Ruby!

Seja Feliz com Ruby!

Palestra apresentada no 1º encontro ABCoDes no ITESCS - Instituto de Tecnologia de São Caetano do Sul.

lucas renan

August 10, 2013
Tweet

More Decks by lucas renan

Other Decks in Programming

Transcript

  1. seja feliz com
    ruby

    View full-size slide

  2. guru
    sorocaba

    View full-size slide

  3. yukihiro matsumoto

    View full-size slide

  4. perl, smalltalk,
    eiffel, ada, lisp

    View full-size slide

  5. ruby permite que
    você seja feliz

    View full-size slide

  6. uhull, valeu matz :)

    View full-size slide

  7. 5.times { puts "We
    love Ruby" }

    View full-size slide

  8. puramente
    orientada a objetos

    View full-size slide

  9. 1.class # => Fixnum

    View full-size slide

  10. 1.class # => Fixnum
    "ruby".class # => String

    View full-size slide

  11. 1.class # => Fixnum
    "ruby".class # => String
    1.to_s.class # => String

    View full-size slide

  12. ruby permite que
    você escreva código
    elegante

    View full-size slide

  13. class Person
    end
    person = Person.new

    View full-size slide

  14. class Person
    attr_accessor :name
    end
    person = Person.new
    person.name = "lucas"

    View full-size slide

  15. class Person
    attr_accessor :name, :age
    end
    person = Person.new
    person.name = "lucas"
    person.age = 24
    puts person.age # => 24

    View full-size slide

  16. class Person
    attr_accessor :name, :age
    def is_adult?
    @age > 18
    end
    end
    person = Person.new
    person.name = "lucas"
    person.age = 24
    puts person.is_adult? # => true

    View full-size slide

  17. active support

    View full-size slide

  18. require "active_support/all"
    1.day.ago # => 2013-08-09 00:00:00
    -0300

    View full-size slide

  19. require "active_support/all"
    1.day.ago # => 2013-08-09 00:00:00
    -0300
    Date.today.beginning_of_month # => Thu,
    01 Aug 2013

    View full-size slide

  20. require "active_support/all"
    1.day.ago # => 2013-08-09 00:00:00
    -0300
    Date.today.beginning_of_month # => Thu,
    01 Aug 2013
    [1, 2, 3].sum # => 6

    View full-size slide

  21. metaprogramming

    View full-size slide

  22. klass = Class.new do
    end
    Person = klass
    Person.name # => Person

    View full-size slide

  23. klass = Class.new do
    end
    Person = klass
    Person.name # => Person
    person = Person.new

    View full-size slide

  24. klass = Class.new do
    ["say", "scream"].each do |method|
    define_method method do |message|
    "#{method}ing: #{message}"
    end
    end
    end
    Person = klass
    Person.name # => Person
    person = Person.new
    puts person.say "ruby" # => saying: ruby
    puts person.scream "ruby <3" # =>
    screaming: ruby <3

    View full-size slide

  25. instalação

    View full-size slide

  26. até quando você
    vai ficar triste?

    View full-size slide