0
Web in the Cloud                       with RubyTuesday, October 23, 12
Rafael Macedo                                  @macedorafael                          github.com/rafaelmacedoTuesday, Octo...
Ruby é...                                   uma linguagem dinâmica,                      interpretada, e open source com f...
Ruby é...         “Eu queria uma linguagem que        fosse mais poderosa que o Perl          e mais orientada a objetos d...
python                 smalltalk                                                   lisp                          eiffel   ...
Como aprender???Tuesday, October 23, 12
http://www.ruby-lang.org/enTuesday, October 23, 12
http://www.ruby-doc.orgTuesday, October 23, 12
http://www.rubydoc.infoTuesday, October 23, 12
http://api.rubyonrails.orgTuesday, October 23, 12
http://guides.rubyonrails.orgTuesday, October 23, 12
http://stackoverflow.com/search?q=ruby+rubyonrailsTuesday, October 23, 12
http://git-scm.com                          http://try.github.com                                      http://github.comTu...
http://git-scm.com                          http://try.github.com                                      http://github.comTu...
http://google.comTuesday, October 23, 12
FTW!!!!                              http://google.comTuesday, October 23, 12
Por que Ruby???Tuesday, October 23, 12
~   1 milhão                          de desenvolvedores                          4M até 2013 (Gartner)Tuesday, October 23...
Tuesday, October 23, 12
Tuesday, October 23, 12
Documentação                     •    112 bibliotecas 100% documentadas                     •    Comunidade ativa         ...
RubygemsTuesday, October 23, 12
Rubygems                          + 40K gemsTuesday, October 23, 12
Rubygems                          + 40K gems                          62.837 usersTuesday, October 23, 12
GithubTuesday, October 23, 12
Sintaxe elegante e limpa                          1 def say_good_morning(name)                          2    return "Good ...
Sintaxe elegante e limpa                          1 def say_good_morning(name)                          2    return "Good ...
Sintaxe elegante e limpa                          1 def say_good_morning(name)                          2    return "Good ...
Sintaxe elegante e limpa                          retorno automático                          1 def say_good_morning(name)...
Sintaxe elegante e limpa                          1 def say_good_morning(name)                          2    "Good morning...
Sintaxe elegante e limpa                                                 interpolação                          1 def say_g...
Sintaxe elegante e limpa                          1 def say_good_morning(name)                          2    "Good morning...
Orientada a objetos                     1    "some dummy text".class                     2    >> String                   ...
Orientada a objetos                     1    "some dummy text".class                     2    >> String                   ...
Orientada a objetos                     1    "some dummy text".class                     2    >> String                   ...
Orientada a objetos                     1    "some dummy text".class                     2    >> String                   ...
Orientada a objetos                     1    "some dummy text".class                     2    >> String                   ...
Orientada a objetos                     1    "some dummy text".class                     2    >> String                   ...
Orientada a objetos                     1    "some dummy text".class                     2    >> String                   ...
Orientada a objetos                     1    "some dummy text".class                     2    >> String                   ...
Orientada a objetos                          1 puts 1 + 1                          2 >> 2Tuesday, October 23, 12
Orientada a objetos                          1   puts 1 + 1                          2   >> 2                          3  ...
Orientada a objetos                          1 [1, 2, 3, 4, 5].averageTuesday, October 23, 12
Orientada a objetos                      1 [1, 2, 3, 4, 5].average                      2 >> NoMethodError: undefined meth...
Orientada a objetos                      1 [1, 2, 3, 4, 5].average                      2 >> NoMethodError: undefined meth...
Orientada a objetos                     1    class Array                     2      def average                     3     ...
Orientada a objetos                     1    class Array                     2      def average                     3     ...
“Se anda como um pato e fala                          como um pato, isso é um pato!”Tuesday, October 23, 12
Desenvolvedores Ruby estão mais                             acostumados em definir objetos                          pelo qu...
Duck Typing                     1 class Logger                     2   def initialize(io)                     3     @io = ...
Duck Typing                          1   array_logger = Logger.new([])                          2   array_logger.log("Hell...
Duck Typing                          1   array_logger = Logger.new([])                          2   array_logger.log("Hell...
InstalaçãoTuesday, October 23, 12
Instalando     (Mac OS & Linux)                          http://rvm.ioTuesday, October 23, 12
Instalando                       (Mac OS & Linux)                          $ curl -L https://get.rvm.io | bash -s stable  ...
Instalando                     (Mac OS & Linux)                     $ echo [[ -s "$HOME/.rvm/scripts/rvm" ]] &&           ...
Instalando               (Mac OS & Linux)                          $ rvm list known                                    htt...
Tuesday, October 23, 12
Instalando                       (Mac OS & Linux)                          $ rvm install ruby-1.9.3                       ...
Instalando                  (Mac OS & Linux)                          $ rvm list                                       htt...
Tuesday, October 23, 12
Instalando                (Windows)                          http://rubyinstaller.org/downloadsTuesday, October 23, 12
“Hello World”Tuesday, October 23, 12
C                          1 #include <stdio.h>                          2                          3 int main(void){     ...
Java                    1 class HelloWorldApp {                    2   public static void main(String[] args) {           ...
Ruby                          1 puts "Hello World"Tuesday, October 23, 12
Rodando códigos                               rubyTuesday, October 23, 12
via irb                          IRB = Interactive RuBy                          Shell REPL (Read Eval Print Loop)Tuesday,...
via irbTuesday, October 23, 12
Tuesday, October 23, 12
via programas Ruby                          $ ruby hello_world.rb                          Hello WorldTuesday, October 23,...
Ruby BasicsTuesday, October 23, 12
ComentáriosTuesday, October 23, 12
Comentários                     1 # comentar uma linha simples                     2                     3 =begin         ...
VariáveisTuesday, October 23, 12
Variáveis                          1   age = 1 # local                          2                          3   @name = raf...
StringsTuesday, October 23, 12
Strings                    1 single_quote = this is a string                    with single quote                    2    ...
Strings              (interpolação)                          1 puts "20 + 20 = #{20 + 20}"                          2 >> 2...
SymbolsTuesday, October 23, 12
Symbols                          1 def walk(direction)                          2   case direction                        ...
Symbols                          1 def walk(direction)                          2   case direction                        ...
Symbols                          1 def walk(direction)                          2   case direction                        ...
NumbersTuesday, October 23, 12
Numbers                     1 number = 15                     2                     3 number_with_delimeter = 1_000_000   ...
Numbers               (conversão automática                entre tipos)                          a = 1                b = ...
Numbers                 (conversão automática                entre tipos)                          a = 1                  ...
Numbers                 (conversão automática                entre tipos)                          a = 1                  ...
ArraysTuesday, October 23, 12
Arrays                    1     items = [1, "two", :three, [4, 5, 6]]                    2                    3     items ...
Arrays                 1 puts items.inspect                 2 >> [1, "two", :three, [4, 5, 6], 7,                 nil, nil...
Arrays                                     [                   1 year_months = %w seg ter qua qui sex sab dom]            ...
Arrays                                     (                   1 year_months = %w seg ter qua qui sex sab dom)            ...
Arrays                     1 items = Array.new(5) { |i| 2 ** i }                     2 >> [1, 2, 4, 8, 16]Tuesday, October...
HashesTuesday, October 23, 12
Hashes                    1 market_list = {:rice => 1, "vegetables"                    => [ :spinach => 1, :broccoli => 2]...
RangesTuesday, October 23, 12
Ranges                    1 (1..10).to_a                    2 >> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]                    3     ...
Ranges                          1   string = "1a".."2g"                          2   string.cover "2a"                    ...
Expressões                           RegularesTuesday, October 23, 12
Expressões regulares                     1 regexp = /(a-z)+/                     2                     3 regexp = %r((a-z)...
Expressões regulares                     1 regexp = /(a-z)+/                     2                     3 regexp = %r((a-z)...
Expressões regularesTuesday, October 23, 12
Estruturas                          condicionaisTuesday, October 23, 12
Estruturas condicionais              (if/elsif/else)                          1   if expression                          2...
Estruturas condicionais              (if/elsif/else)                          1 if !expression                          2 ...
Estruturas condicionais              (if/elsif/else)                          1 if !expression                          2 ...
Estruturas condicionais              (if/elsif/else)                          1   if !expression                          ...
Estruturas condicionais              (if/elsif/else)                   1 count == 1 ? singular : pluralTuesday, October 23...
Estruturas condicionais              (case)                          1   case                          2   when x == 1 the...
Estruturas condicionais              (case)                          1 case number                          2 when 0..10  ...
Estruturas condicionais              (case)                    1     case text                    2     when /brubyb/     ...
IteradoresTuesday, October 23, 12
Iteradores                      Objetos das class Hash, Array e Range são                                       iteráveis ...
MétodosTuesday, October 23, 12
Métodos                          1 def greet(name)                          2   puts "Hello #{name}"                      ...
Métodos               (argumento padrão)                          1 def greet(name="there")                          2   p...
Métodos                   (escopo)                     1    x, y = 2, 1                     2                     3    def...
Métodos                   (retorno automático)                     1    x, y = 2, 1                     2                 ...
ClassesTuesday, October 23, 12
Classes                          1 class Person                          2 end                          3                 ...
Classes               (métodos de instância)                          1   class Person                          2     def ...
Classes         (construtor)                 1 class Person                 2   def initialize(name)                 3    ...
Classes              (métodos de classe)                          1 class Animal                          2   def self.spe...
Classes              (getters e setters)                    1 class Person                    2   def name=(name)         ...
Classes             (getters e setters)                    1     class Person                    2       attr_accessor :na...
Classes         (getters)                    1 class Person                    2   attr_reader :name                    3 ...
Classes         (setters)                    1 class Person                    2   attr_reader :name                    3 ...
Classes                (inheritance)                          1   class Studend < Person                          2     at...
Classes             (modules)                          1 module Swimmer                          2   def swim             ...
Classes                (modules)                          1   class Person                          2     include Swimmer ...
Quem usa?Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
O que posso                            fazer?Tuesday, October 23, 12
Aplicações de voz                     • Interactive voice response systems                       (IVRs)                   ...
Aplicações linha de                comandoTuesday, October 23, 12
Games             https://github.com/qwertyreddy/rubysteinTuesday, October 23, 12
Aplicações desktopTuesday, October 23, 12
Desktop ApplicationsTuesday, October 23, 12
Web ApplicationsTuesday, October 23, 12
Web ApplicationsTuesday, October 23, 12
Web ApplicationsTuesday, October 23, 12
Web ApplicationsTuesday, October 23, 12
Web ApplicationsTuesday, October 23, 12
Rails is...                 Ruby on Rails® is an open-source web                         framework that’s optimized for   ...
Rails is...                          Ruby on Rails is intended to                           emphasize Convention over     ...
Rails is...                   Ruby on Rails is intended to emphasize                      Convention over Configuration (Co...
Rails is...                   Ruby on Rails is intended to emphasize                      Convention over Configuration (Co...
Rails is...                   Ruby on Rails is intended to emphasize                      Convention over Configuration (Co...
$ gem install rails                          $ rails new my-app -d mysqlTuesday, October 23, 12
Tuesday, October 23, 12
Routes                             Controller                          View        ModelTuesday, October 23, 12
Routes                             Controller                          View        ModelTuesday, October 23, 12
Routes                             Controller                          View        ModelTuesday, October 23, 12
Routes                             Controller                          View        ModelTuesday, October 23, 12
Routes                             Controller                          View        ModelTuesday, October 23, 12
Routes                             Controller                          View        ModelTuesday, October 23, 12
Routes                             Controller                          View        ModelTuesday, October 23, 12
Routes                             Controller                          View        ModelTuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
bundle installTuesday, October 23, 12
Tuesday, October 23, 12
rake -TTuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
rake db:createTuesday, October 23, 12
Tuesday, October 23, 12
rails generateTuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
rake routesTuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
rake db:migrateTuesday, October 23, 12
Tuesday, October 23, 12
rails sTuesday, October 23, 12
rails sTuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
Tuesday, October 23, 12
WIN!!!!Tuesday, October 23, 12
...Tuesday, October 23, 12
Ajuda adicionalTuesday, October 23, 12
http://try.github.comTuesday, October 23, 12
http://caelum.com.brTuesday, October 23, 12
http://railscasts.comTuesday, October 23, 12
http://howtocode.com.brTuesday, October 23, 12
10 dicas para o                              sucessoTuesday, October 23, 12
1. Faça apenas uma                             tarefa por vezTuesday, October 23, 12
2. Conheça o                            problemaTuesday, October 23, 12
3. Aprenda a ouvirTuesday, October 23, 12
4. Faça perguntasTuesday, October 23, 12
6. Aceite mudançasTuesday, October 23, 12
7. Admita seus errosTuesday, October 23, 12
8. Mantenha as                           coisas simplesTuesday, October 23, 12
9. Mantenha calmaTuesday, October 23, 12
10. SorriaTuesday, October 23, 12
10. SorriaTuesday, October 23, 12
Tuesday, October 23, 12
OBRIGADO!!!               https://speakerdeck.com/u/rafaelmacedoTuesday, October 23, 12
Upcoming SlideShare
Loading in...5
×

Wewebconf

306

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
306
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Wewebconf"

  1. 1. Web in the Cloud with RubyTuesday, October 23, 12
  2. 2. Rafael Macedo @macedorafael github.com/rafaelmacedoTuesday, October 23, 12
  3. 3. Ruby é... uma linguagem dinâmica, interpretada, e open source com foco em simplicidade e produtividade. Possui uma sintaxe elegante que é natural de ler e fácil de escrever. http://ruby-lang.org/enTuesday, October 23, 12
  4. 4. Ruby é... “Eu queria uma linguagem que fosse mais poderosa que o Perl e mais orientada a objetos do que o Python.” Yukihiro “Matz” MatsumotoTuesday, October 23, 12
  5. 5. python smalltalk lisp eiffel perlTuesday, October 23, 12
  6. 6. Como aprender???Tuesday, October 23, 12
  7. 7. http://www.ruby-lang.org/enTuesday, October 23, 12
  8. 8. http://www.ruby-doc.orgTuesday, October 23, 12
  9. 9. http://www.rubydoc.infoTuesday, October 23, 12
  10. 10. http://api.rubyonrails.orgTuesday, October 23, 12
  11. 11. http://guides.rubyonrails.orgTuesday, October 23, 12
  12. 12. http://stackoverflow.com/search?q=ruby+rubyonrailsTuesday, October 23, 12
  13. 13. http://git-scm.com http://try.github.com http://github.comTuesday, October 23, 12
  14. 14. http://git-scm.com http://try.github.com http://github.comTuesday, October 23, 12
  15. 15. http://google.comTuesday, October 23, 12
  16. 16. FTW!!!! http://google.comTuesday, October 23, 12
  17. 17. Por que Ruby???Tuesday, October 23, 12
  18. 18. ~ 1 milhão de desenvolvedores 4M até 2013 (Gartner)Tuesday, October 23, 12
  19. 19. Tuesday, October 23, 12
  20. 20. Tuesday, October 23, 12
  21. 21. Documentação • 112 bibliotecas 100% documentadas • Comunidade ativa • Diversos tutoriais e em diversos níveis • Bibliotecas em ruby são empacotadas e distribuidas como gemsTuesday, October 23, 12
  22. 22. RubygemsTuesday, October 23, 12
  23. 23. Rubygems + 40K gemsTuesday, October 23, 12
  24. 24. Rubygems + 40K gems 62.837 usersTuesday, October 23, 12
  25. 25. GithubTuesday, October 23, 12
  26. 26. Sintaxe elegante e limpa 1 def say_good_morning(name) 2 return "Good morning " + name + "!!!" • 3 end 4 dasdasdasd 5 puts say_good_morning("folks") 6 >> Good morning folks!!!Tuesday, October 23, 12
  27. 27. Sintaxe elegante e limpa 1 def say_good_morning(name) 2 return "Good morning " + name + "!!!" • 3 end 4 dasdasdasd 5 puts say_good_morning("folks") 6 >> Good morning folks!!! opcionaisTuesday, October 23, 12
  28. 28. Sintaxe elegante e limpa 1 def say_good_morning(name) 2 return "Good morning " + name + "!!!" • 3 end 4 dasdasdasd 5 puts say_good_morning "folks" 6 >> Good morning folks!!!Tuesday, October 23, 12
  29. 29. Sintaxe elegante e limpa retorno automático 1 def say_good_morning(name) 2 return "Good morning " + name + "!!!" • 3 end 4 dasdasdasd 5 puts say_good_morning "folks" 6 >> Good morning folks!!!Tuesday, October 23, 12
  30. 30. Sintaxe elegante e limpa 1 def say_good_morning(name) 2 "Good morning " + name + "!!!" • 3 end 4 dasdasdasd 5 puts say_good_morning "folks" 6 >> Good morning folks!!!Tuesday, October 23, 12
  31. 31. Sintaxe elegante e limpa interpolação 1 def say_good_morning(name) 2 "Good morning " + name + "!!!" • 3 end 4 dasdasdasd 5 puts say_good_morning "folks" 6 >> Good morning folks!!!Tuesday, October 23, 12
  32. 32. Sintaxe elegante e limpa 1 def say_good_morning(name) 2 "Good morning #{name}!!!" • 3 end 4 dasdasdasd 5 puts say_good_morning "folks" 6 >> Good morning folks!!!Tuesday, October 23, 12
  33. 33. Orientada a objetos 1 "some dummy text".class 2 >> String 3 4 1.class 5 >> Fixnum 6 7 true.class 8 >> TrueClass 9 10 nil.class 11 >> NilClassTuesday, October 23, 12
  34. 34. Orientada a objetos 1 "some dummy text".class 2 >> String 3 4 1.class 5 >> Fixnum 6 7 true.class 8 >> TrueClass 9 10 nil.class 11 >> NilClassTuesday, October 23, 12
  35. 35. Orientada a objetos 1 "some dummy text".class 2 >> String 3 4 1.class 5 >> Fixnum 6 7 true.class 8 >> TrueClass 9 10 nil.class 11 >> NilClassTuesday, October 23, 12
  36. 36. Orientada a objetos 1 "some dummy text".class 2 >> String 3 4 1.class 5 >> Fixnum 6 7 true.class 8 >> TrueClass 9 10 nil.class 11 >> NilClassTuesday, October 23, 12
  37. 37. Orientada a objetos 1 "some dummy text".class 2 >> String 3 4 1.class 5 >> Fixnum 6 7 true.class 8 >> TrueClass 9 10 nil.class 11 >> NilClassTuesday, October 23, 12
  38. 38. Orientada a objetos 1 "some dummy text".class 2 >> String 3 4 1.class 5 >> Fixnum 6 tudo é um objeto 7 true.class 8 >> TrueClass 9 10 nil.class 11 >> NilClassTuesday, October 23, 12
  39. 39. Orientada a objetos 1 "some dummy text".class 2 >> String 3 4 1.class 5 >> Fixnum 6 sim, eu disse tudo!!! 7 true.class 8 >> TrueClass 9 10 nil.class 11 >> NilClassTuesday, October 23, 12
  40. 40. Orientada a objetos 1 "some dummy text".class 2 >> String 3 4 1.class 5 >> Fixnum 6 sim, eu disse tudo!!! 7 true.class 8 >> TrueClass 1 String.class 9 2 >> Class 10 nil.class 11 >> NilClassTuesday, October 23, 12
  41. 41. Orientada a objetos 1 puts 1 + 1 2 >> 2Tuesday, October 23, 12
  42. 42. Orientada a objetos 1 puts 1 + 1 2 >> 2 3 4 puts 1.+(1) 5 >> 2Tuesday, October 23, 12
  43. 43. Orientada a objetos 1 [1, 2, 3, 4, 5].averageTuesday, October 23, 12
  44. 44. Orientada a objetos 1 [1, 2, 3, 4, 5].average 2 >> NoMethodError: undefined method `average for [1, 2, 3, 4, 5]:ArrayTuesday, October 23, 12
  45. 45. Orientada a objetos 1 [1, 2, 3, 4, 5].average 2 >> NoMethodError: undefined method `average for [1, 2, 3, 4, 5]:Array e agora???????Tuesday, October 23, 12
  46. 46. Orientada a objetos 1 class Array 2 def average 3 inject(0.0) do |sum, var| 4 sum + var 5 end / self.size 6 end 7 end 8 9 [1, 2, 3, 4, 5].average 10 >> 3.0Tuesday, October 23, 12
  47. 47. Orientada a objetos 1 class Array 2 def average 3 inject(0.0) do |sum, var| 4 sum + var 5 6 open classes WINS!!!! end / self.size end 7 end 8 9 [1, 2, 3, 4, 5].average 10 >> 3.0Tuesday, October 23, 12
  48. 48. “Se anda como um pato e fala como um pato, isso é um pato!”Tuesday, October 23, 12
  49. 49. Desenvolvedores Ruby estão mais acostumados em definir objetos pelo que eles podem fazer, do que por seu tipo. Esta técnica é chamada de duck typing.Tuesday, October 23, 12
  50. 50. Duck Typing 1 class Logger 2 def initialize(io) 3 @io = io 4 end 5 6 def log(message) 7 @io << "#{Time.now} - #{message}n" 8 end 9 endTuesday, October 23, 12
  51. 51. Duck Typing 1 array_logger = Logger.new([]) 2 array_logger.log("Hello World") 3 4 string_logger = Logger.new("") 5 string_logger.log("Hello World")Tuesday, October 23, 12
  52. 52. Duck Typing 1 array_logger = Logger.new([]) 2 array_logger.log("Hello World") 3 4 Protocolo= > Interface string_logger Logger.new("") 5 string_logger.log("Hello World")Tuesday, October 23, 12
  53. 53. InstalaçãoTuesday, October 23, 12
  54. 54. Instalando (Mac OS & Linux) http://rvm.ioTuesday, October 23, 12
  55. 55. Instalando (Mac OS & Linux) $ curl -L https://get.rvm.io | bash -s stable $ source ~/.rvm/scripts/rvm $ type rvm | head -n 1 rvm is a function http://rvm.ioTuesday, October 23, 12
  56. 56. Instalando (Mac OS & Linux) $ echo [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" > ~/.bash_profile http://rvm.ioTuesday, October 23, 12
  57. 57. Instalando (Mac OS & Linux) $ rvm list known http://rvm.ioTuesday, October 23, 12
  58. 58. Tuesday, October 23, 12
  59. 59. Instalando (Mac OS & Linux) $ rvm install ruby-1.9.3 $ rvm use ruby-1.9.3 http://rvm.ioTuesday, October 23, 12
  60. 60. Instalando (Mac OS & Linux) $ rvm list http://rvm.ioTuesday, October 23, 12
  61. 61. Tuesday, October 23, 12
  62. 62. Instalando (Windows) http://rubyinstaller.org/downloadsTuesday, October 23, 12
  63. 63. “Hello World”Tuesday, October 23, 12
  64. 64. C 1 #include <stdio.h> 2 3 int main(void){ 4 printf("Hello Worldn"); 5 return 1; 6 }Tuesday, October 23, 12
  65. 65. Java 1 class HelloWorldApp { 2 public static void main(String[] args) { 3 System.out.println("Hello World"); 4 } 5 }Tuesday, October 23, 12
  66. 66. Ruby 1 puts "Hello World"Tuesday, October 23, 12
  67. 67. Rodando códigos rubyTuesday, October 23, 12
  68. 68. via irb IRB = Interactive RuBy Shell REPL (Read Eval Print Loop)Tuesday, October 23, 12
  69. 69. via irbTuesday, October 23, 12
  70. 70. Tuesday, October 23, 12
  71. 71. via programas Ruby $ ruby hello_world.rb Hello WorldTuesday, October 23, 12
  72. 72. Ruby BasicsTuesday, October 23, 12
  73. 73. ComentáriosTuesday, October 23, 12
  74. 74. Comentários 1 # comentar uma linha simples 2 3 =begin 4 para um bloco de códigos 5 [1, 2, 3].each do |number| 6 puts number * 2 7 end 8 =endTuesday, October 23, 12
  75. 75. VariáveisTuesday, October 23, 12
  76. 76. Variáveis 1 age = 1 # local 2 3 @name = rafael # global 4 5 @@count = 1 # class 6 7 PATH = ~/ # constantTuesday, October 23, 12
  77. 77. StringsTuesday, October 23, 12
  78. 78. Strings 1 single_quote = this is a string with single quote 2 3 double_quote = "this is a string with double quote" 4 5 escaped_string = im a escaped stringTuesday, October 23, 12
  79. 79. Strings (interpolação) 1 puts "20 + 20 = #{20 + 20}" 2 >> 20 + 20 = 40Tuesday, October 23, 12
  80. 80. SymbolsTuesday, October 23, 12
  81. 81. Symbols 1 def walk(direction) 2 case direction 3 when 1 then move_north 4 when 2 then move_east 5 when 3 then move_south 6 when 4 then move_west 7 else "Unknown direction" 8 endTuesday, October 23, 12
  82. 82. Symbols 1 def walk(direction) 2 case direction 3 when :north then move_north 4 when :east then move_east 5 when :south then move_south 6 when :west then move_west 7 else "Unknown direction" 8 endTuesday, October 23, 12
  83. 83. Symbols 1 def walk(direction) 2 case direction 3 when :north then move_north 4 when :east then move_east 5 when :south then move_south 6 when :west then move_west 7 else "Unknown direction" 8 endTuesday, October 23, 12
  84. 84. NumbersTuesday, October 23, 12
  85. 85. Numbers 1 number = 15 2 3 number_with_delimeter = 1_000_000 4 5 float = 1.5Tuesday, October 23, 12
  86. 86. Numbers (conversão automática entre tipos) a = 1 b = 5.5 a.class b.class >> Fixnum >> FloatTuesday, October 23, 12
  87. 87. Numbers (conversão automática entre tipos) a = 1 b = 5.5 a.class b.class >> Fixnum >> Float c = a + b >> 6.5Tuesday, October 23, 12
  88. 88. Numbers (conversão automática entre tipos) a = 1 b = 5.5 a.class b.class >> Fixnum >> Float c = a + b >> 6.5 c.class >> FloatTuesday, October 23, 12
  89. 89. ArraysTuesday, October 23, 12
  90. 90. Arrays 1 items = [1, "two", :three, [4, 5, 6]] 2 3 items << 7 4 5 items[12] = a 6 7 puts items[0] 8 >> 1Tuesday, October 23, 12
  91. 91. Arrays 1 puts items.inspect 2 >> [1, "two", :three, [4, 5, 6], 7, nil, nil, nil, nil, nil, nil, nil, "..."]Tuesday, October 23, 12
  92. 92. Arrays [ 1 year_months = %w seg ter qua qui sex sab dom] 2 >> ["seg", "ter", "qua", "qui", "sex", "sab", “dom"]Tuesday, October 23, 12
  93. 93. Arrays ( 1 year_months = %w seg ter qua qui sex sab dom) 2 >> ["seg", "ter", "qua", "qui", "sex", "sab", “dom"]Tuesday, October 23, 12
  94. 94. Arrays 1 items = Array.new(5) { |i| 2 ** i } 2 >> [1, 2, 4, 8, 16]Tuesday, October 23, 12
  95. 95. HashesTuesday, October 23, 12
  96. 96. Hashes 1 market_list = {:rice => 1, "vegetables" => [ :spinach => 1, :broccoli => 2]} 2 3 market_list = {rice: 1, vegetables: [ spinach: 1, broccoli: 2 ]} 4 5 market_list[:rice] 6 7 market_list[:coca] = 2Tuesday, October 23, 12
  97. 97. RangesTuesday, October 23, 12
  98. 98. Ranges 1 (1..10).to_a 2 >> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 3 4 (1...10).to_a 5 >> [1, 2, 3, 4, 5, 6, 7, 8, 9] 6 7 ("a".."z").to_a 8 >> ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]Tuesday, October 23, 12
  99. 99. Ranges 1 string = "1a".."2g" 2 string.cover "2a" 3 >> true 4 5 string.cover "2h" 6 >> falseTuesday, October 23, 12
  100. 100. Expressões RegularesTuesday, October 23, 12
  101. 101. Expressões regulares 1 regexp = /(a-z)+/ 2 3 regexp = %r((a-z)+)Tuesday, October 23, 12
  102. 102. Expressões regulares 1 regexp = /(a-z)+/ 2 3 regexp = %r((a-z)+) Metacaracteres devem ser escapados ( ) [ ] { } . ? + *Tuesday, October 23, 12
  103. 103. Expressões regularesTuesday, October 23, 12
  104. 104. Estruturas condicionaisTuesday, October 23, 12
  105. 105. Estruturas condicionais (if/elsif/else) 1 if expression 2 # do something 3 elsif expression2 4 # do something else 5 elsif expressionN 6 # do something else 7 else 8 # do something else 9 endTuesday, October 23, 12
  106. 106. Estruturas condicionais (if/elsif/else) 1 if !expression 2 # do something 3 endTuesday, October 23, 12
  107. 107. Estruturas condicionais (if/elsif/else) 1 if !expression 2 # do something 3 endTuesday, October 23, 12
  108. 108. Estruturas condicionais (if/elsif/else) 1 if !expression 2 # do something 3 end 4 5 unless expression 6 # do something 7 endTuesday, October 23, 12
  109. 109. Estruturas condicionais (if/elsif/else) 1 count == 1 ? singular : pluralTuesday, October 23, 12
  110. 110. Estruturas condicionais (case) 1 case 2 when x == 1 then "one" 3 when x == 2 then "two" 4 when x == 3 then "three" 5 else"other"Tuesday, October 23, 12
  111. 111. Estruturas condicionais (case) 1 case number 2 when 0..10 3 "Between 0 and 10" 4 when 11..20 5 "Between 11 and 20" 6 else 7 "Youre outside my limits" 8 endTuesday, October 23, 12
  112. 112. Estruturas condicionais (case) 1 case text 2 when /brubyb/ 3 "You passed a lowercased Ruby" 4 when /bRubyb/ 5 "You passed a capitalized Ruby" 6 when /bRUBYb/ 7 "You passed an uppercased Ruby" 8 else 9 "WAT? NO RUBY?" 10 endTuesday, October 23, 12
  113. 113. IteradoresTuesday, October 23, 12
  114. 114. Iteradores Objetos das class Hash, Array e Range são iteráveis 1 1.upto(3) do |number| 2 puts number 3 end 4 5 [1, 2, 3].map { |number| number * 2 } 6 >> [2, 4, 6] 7 8 (1..10).reject { |number| number.odd? } 9 >> [2, 4, 6, 8, 10]Tuesday, October 23, 12
  115. 115. MétodosTuesday, October 23, 12
  116. 116. Métodos 1 def greet(name) 2 puts "Hello #{name}" 3 end 4 5 greet "Rafael"Tuesday, October 23, 12
  117. 117. Métodos (argumento padrão) 1 def greet(name="there") 2 puts "Hello #{name}" 3 end 4 5 greetTuesday, October 23, 12
  118. 118. Métodos (escopo) 1 x, y = 2, 1 2 3 def cube(x) 4 y = x**3 5 return y 6 end 7 8 puts cube(x) 9 >> 8 10 11 puts y 12 >> 1Tuesday, October 23, 12
  119. 119. Métodos (retorno automático) 1 x, y = 2, 1 2 3 def cube(x) 4 x**3 5 end 6 7 puts cube(x) 8 >> 8 9 10 puts y 11 >> 1Tuesday, October 23, 12
  120. 120. ClassesTuesday, October 23, 12
  121. 121. Classes 1 class Person 2 end 3 4 p = Person.newTuesday, October 23, 12
  122. 122. Classes (métodos de instância) 1 class Person 2 def introduce 3 puts "Hello" 4 end 5 end 6 7 p = Person.new 8 p.introduce 9 >> HelloTuesday, October 23, 12
  123. 123. Classes (construtor) 1 class Person 2 def initialize(name) 3 @name = name # variavel de instância 4 end 5 6 def introduce 7 puts "Hello my name is #{@name}" 8 end 9 end 1 p = Person.new(rafael) 2 p.introduce 3 >> Hello my name is rafaelTuesday, October 23, 12
  124. 124. Classes (métodos de classe) 1 class Animal 2 def self.species 3 ["alligator", "bat", ..., "bear"] 4 end 5 end 6 7 puts Animal.speciesTuesday, October 23, 12
  125. 125. Classes (getters e setters) 1 class Person 2 def name=(name) 3 @name = name 4 end 5 6 def name 7 @name 8 end 9 end 10 11 p = Person.new(rafael) 12 p.name = macedo 13 puts p.name 14 >> macedoTuesday, October 23, 12
  126. 126. Classes (getters e setters) 1 class Person 2 attr_accessor :name 3 end 4 5 p = Person.new(rafael) 6 p.name = macedo 7 puts p.name 8 >> macedoTuesday, October 23, 12
  127. 127. Classes (getters) 1 class Person 2 attr_reader :name 3 end 4 5 p = Person.new(rafael) 6 p.name = macedo 7 NoMethodError: undefined method `name= 8 puts p.name 8 >> macedoTuesday, October 23, 12
  128. 128. Classes (setters) 1 class Person 2 attr_reader :name 3 end 4 5 p = Person.new(rafael) 6 p.name = macedo 7 puts p.name 8 NoMethodError: undefined method `nameTuesday, October 23, 12
  129. 129. Classes (inheritance) 1 class Studend < Person 2 attr_accessor :register 3 end 4 5 s = Studend.new(rafael) 6 s.register = 13286 7 s.name = macedoTuesday, October 23, 12
  130. 130. Classes (modules) 1 module Swimmer 2 def swim 3 puts Im swimming! 4 end 5 endTuesday, October 23, 12
  131. 131. Classes (modules) 1 class Person 2 include Swimmer 3 end 4 5 Person.new.swim 6 >> Im swimming!Tuesday, October 23, 12
  132. 132. Quem usa?Tuesday, October 23, 12
  133. 133. Tuesday, October 23, 12
  134. 134. Tuesday, October 23, 12
  135. 135. Tuesday, October 23, 12
  136. 136. Tuesday, October 23, 12
  137. 137. Tuesday, October 23, 12
  138. 138. Tuesday, October 23, 12
  139. 139. Tuesday, October 23, 12
  140. 140. Tuesday, October 23, 12
  141. 141. Tuesday, October 23, 12
  142. 142. Tuesday, October 23, 12
  143. 143. O que posso fazer?Tuesday, October 23, 12
  144. 144. Aplicações de voz • Interactive voice response systems (IVRs) • Call Center Automation • Data Gathering • Voice 2.0 http://adhearsion.comTuesday, October 23, 12
  145. 145. Aplicações linha de comandoTuesday, October 23, 12
  146. 146. Games https://github.com/qwertyreddy/rubysteinTuesday, October 23, 12
  147. 147. Aplicações desktopTuesday, October 23, 12
  148. 148. Desktop ApplicationsTuesday, October 23, 12
  149. 149. Web ApplicationsTuesday, October 23, 12
  150. 150. Web ApplicationsTuesday, October 23, 12
  151. 151. Web ApplicationsTuesday, October 23, 12
  152. 152. Web ApplicationsTuesday, October 23, 12
  153. 153. Web ApplicationsTuesday, October 23, 12
  154. 154. Rails is... Ruby on Rails® is an open-source web framework that’s optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration http://rubyonrails.orgTuesday, October 23, 12
  155. 155. Rails is... Ruby on Rails is intended to emphasize Convention over Configuration (CoC)Tuesday, October 23, 12
  156. 156. Rails is... Ruby on Rails is intended to emphasize Convention over Configuration (CoC) Rapid development principle of Dont Repeat Yourself (DRY)Tuesday, October 23, 12
  157. 157. Rails is... Ruby on Rails is intended to emphasize Convention over Configuration (CoC) Rapid development principle of Dont Repeat Yourself (DRY) Fat models, skinny controllersTuesday, October 23, 12
  158. 158. Rails is... Ruby on Rails is intended to emphasize Convention over Configuration (CoC) Rapid development principle of Dont Repeat Yourself (DRY) Fat models, skinny controllersTuesday, October 23, 12
  159. 159. $ gem install rails $ rails new my-app -d mysqlTuesday, October 23, 12
  160. 160. Tuesday, October 23, 12
  161. 161. Routes Controller View ModelTuesday, October 23, 12
  162. 162. Routes Controller View ModelTuesday, October 23, 12
  163. 163. Routes Controller View ModelTuesday, October 23, 12
  164. 164. Routes Controller View ModelTuesday, October 23, 12
  165. 165. Routes Controller View ModelTuesday, October 23, 12
  166. 166. Routes Controller View ModelTuesday, October 23, 12
  167. 167. Routes Controller View ModelTuesday, October 23, 12
  168. 168. Routes Controller View ModelTuesday, October 23, 12
  169. 169. Tuesday, October 23, 12
  170. 170. Tuesday, October 23, 12
  171. 171. Tuesday, October 23, 12
  172. 172. Tuesday, October 23, 12
  173. 173. Tuesday, October 23, 12
  174. 174. bundle installTuesday, October 23, 12
  175. 175. Tuesday, October 23, 12
  176. 176. rake -TTuesday, October 23, 12
  177. 177. Tuesday, October 23, 12
  178. 178. Tuesday, October 23, 12
  179. 179. Tuesday, October 23, 12
  180. 180. Tuesday, October 23, 12
  181. 181. rake db:createTuesday, October 23, 12
  182. 182. Tuesday, October 23, 12
  183. 183. rails generateTuesday, October 23, 12
  184. 184. Tuesday, October 23, 12
  185. 185. Tuesday, October 23, 12
  186. 186. Tuesday, October 23, 12
  187. 187. Tuesday, October 23, 12
  188. 188. rake routesTuesday, October 23, 12
  189. 189. Tuesday, October 23, 12
  190. 190. Tuesday, October 23, 12
  191. 191. rake db:migrateTuesday, October 23, 12
  192. 192. Tuesday, October 23, 12
  193. 193. rails sTuesday, October 23, 12
  194. 194. rails sTuesday, October 23, 12
  195. 195. Tuesday, October 23, 12
  196. 196. Tuesday, October 23, 12
  197. 197. Tuesday, October 23, 12
  198. 198. WIN!!!!Tuesday, October 23, 12
  199. 199. ...Tuesday, October 23, 12
  200. 200. Ajuda adicionalTuesday, October 23, 12
  201. 201. http://try.github.comTuesday, October 23, 12
  202. 202. http://caelum.com.brTuesday, October 23, 12
  203. 203. http://railscasts.comTuesday, October 23, 12
  204. 204. http://howtocode.com.brTuesday, October 23, 12
  205. 205. 10 dicas para o sucessoTuesday, October 23, 12
  206. 206. 1. Faça apenas uma tarefa por vezTuesday, October 23, 12
  207. 207. 2. Conheça o problemaTuesday, October 23, 12
  208. 208. 3. Aprenda a ouvirTuesday, October 23, 12
  209. 209. 4. Faça perguntasTuesday, October 23, 12
  210. 210. 6. Aceite mudançasTuesday, October 23, 12
  211. 211. 7. Admita seus errosTuesday, October 23, 12
  212. 212. 8. Mantenha as coisas simplesTuesday, October 23, 12
  213. 213. 9. Mantenha calmaTuesday, October 23, 12
  214. 214. 10. SorriaTuesday, October 23, 12
  215. 215. 10. SorriaTuesday, October 23, 12
  216. 216. Tuesday, October 23, 12
  217. 217. OBRIGADO!!! https://speakerdeck.com/u/rafaelmacedoTuesday, October 23, 12
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×