SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
puts “Hello Ruby!”
Clean, Elegant
      and
Meaningful Syntax
test_string = 'string for test'
puts 'matched' if test_string.match 'string'




files = Dir['*.txt']
for file in files
    file_ref = open file
    file_ref.each_line { |line| puts line.reverse.upcase }
end
Everything is an Object


10.times { puts “Hello World!” }   “Hello World!”.methods
Dynamic Typing,
  Duck Typing
     and
 Open Classes
a_variable = 'a b c'.split(' ')   #=> ['a','b','c']
a_variable = a_variable.join(' ') #=> 'a b c'



def a_function object_par
     puts object_par.crazy_method
end

a_function [1,2,3] #=> error: undefined method 'crazy_method' for class Array

class Array
    def crazy_method
         return 'crazy method for an array'
    end
end

a_function [1,2,3] #=> puts 'crazy method for an array'
a_variable = 'a b c'.split(' ')   #=> ['a','b','c']
a_variable = a_variable.join(' ') #=> 'a b c'



def a_function object_par
     puts object_par.crazy_method
end

a_function [1,2,3] #=> error: undefined method 'crazy_method' for class Array

class Array
    def crazy_method
         return 'crazy method for an array'
    end
end

a_function [1,2,3] #=> puts 'crazy method for an array'
def a_function object_par
     puts object_par.crazy_method
end

some_obj = SomeClass.new

a_function some_obj #=> error: undefined method 'crazy_method' for class SomeClass

def some_obj.crazy_method
     return 'this is a crazy feature'
end

a_function some_obj #=> puts 'this is a crazy_feature'
def a_function object_par
     puts object_par.crazy_method
end

some_obj = SomeClass.new

a_function some_obj #=> error: undefined method 'crazy_method' for class SomeClass

def some_obj.crazy_method
     return 'this is a crazy feature'
end

a_function some_obj #=> puts 'this is a crazy_feature'
"if it walks like a duck and quacks like a
           duck, then it is a duck”
Blocks
def square an_array
    return an_array.map { |e| e*e }
end




lines_of_a_doc.each_with_index do |line,i|
    if i.even? then
          puts 'even line: #{line}'
    else
          puts 'odd line: ' + line
    end
end
[1,2,3,4].select { |e| e.even? }
#=> [2,4]

[1,2,3,4].collect { |e| e.even? }
#=> [true,false,true,false]

[1,2,3,4].inject(0) { |sum,e| sum += e }
#=> 10
def my_for n
   n.times { |n| yield(n) }
end

my_for 3 { |i| puts i }

#=> 1
#=> 2
#=> 3
Mix-in
class Books < Collection
    def initialize
         @books = SomeReader.new('some_file_with_books').get_books
    end

      include Enumerable

      def each
          @books.each { |book| yield(book) }
      end
end




        Class Books now have
 map, select, inject, grep, find_all, include?
                 and more
Testing
require 'test/unit'

class TestHtmlParser < Test::Unit::TestCase

      must “find all imgs” do
          parser = HtmlParser.new '<div class='a'> <br/> <img src='img1.jpg'>n
                                   <p><img src='img2.jpg'></body>'
          assert_equal parser.parse_imgs, ['img1.jpg','img2.jpg']
      end
end

class HtmlParser

      def initialize html_doc
           @content = html_doc
      end

      def parse_imgs
          @content.scan(/imgs+src='(.+?)'/)
      end
end
Standard Library

● erb - .rhtml
● sockets

● threads

● html/xml parser

● ftp, http, imap, pop3, smtp

● tk

● pstore
And Gems!

$ gem install rails

$ gem install rspec

$ gem search twitter

 13,007 gems and counting!
Productivity and fun

    And that's it!



       Duda Dornelles
 dudassdornelles@gmail.com

Weitere ähnliche Inhalte

Was ist angesagt?

Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby MetaprogrammingThaichor Seng
 
Rails 2010 Workshop
Rails 2010 WorkshopRails 2010 Workshop
Rails 2010 Workshopdtsadok
 
Decorators in Python
Decorators in PythonDecorators in Python
Decorators in PythonBen James
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)brian d foy
 
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.Samuel Fortier-Galarneau
 
(Parameterized) Roles
(Parameterized) Roles(Parameterized) Roles
(Parameterized) Rolessartak
 
Moose: Perl Objects
Moose: Perl ObjectsMoose: Perl Objects
Moose: Perl ObjectsLambert Lum
 
Metaprogramming and Folly
Metaprogramming and FollyMetaprogramming and Folly
Metaprogramming and FollyHaseeb Qureshi
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Puppet
 
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...Puppet
 
Designing with Groovy Traits - Gr8Conf India
Designing with Groovy Traits - Gr8Conf IndiaDesigning with Groovy Traits - Gr8Conf India
Designing with Groovy Traits - Gr8Conf IndiaNaresha K
 
Python decorators
Python decoratorsPython decorators
Python decoratorsAlex Su
 
Constructive Destructor Use
Constructive Destructor UseConstructive Destructor Use
Constructive Destructor Usemetaperl
 
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers CracowForget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers CracowKacper Gunia
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.VimLin Yo-An
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 
Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScriptStalin Thangaraj
 

Was ist angesagt? (19)

Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby Metaprogramming
 
PHPSpec BDD for PHP
PHPSpec BDD for PHPPHPSpec BDD for PHP
PHPSpec BDD for PHP
 
Rails 2010 Workshop
Rails 2010 WorkshopRails 2010 Workshop
Rails 2010 Workshop
 
Decorators in Python
Decorators in PythonDecorators in Python
Decorators in Python
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)
 
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
 
(Parameterized) Roles
(Parameterized) Roles(Parameterized) Roles
(Parameterized) Roles
 
Moose: Perl Objects
Moose: Perl ObjectsMoose: Perl Objects
Moose: Perl Objects
 
Metaprogramming and Folly
Metaprogramming and FollyMetaprogramming and Folly
Metaprogramming and Folly
 
Python decorators
Python decoratorsPython decorators
Python decorators
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...
 
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
 
Designing with Groovy Traits - Gr8Conf India
Designing with Groovy Traits - Gr8Conf IndiaDesigning with Groovy Traits - Gr8Conf India
Designing with Groovy Traits - Gr8Conf India
 
Python decorators
Python decoratorsPython decorators
Python decorators
 
Constructive Destructor Use
Constructive Destructor UseConstructive Destructor Use
Constructive Destructor Use
 
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers CracowForget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers Cracow
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScript
 

Ähnlich wie A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles

Metaprogramovanie #1
Metaprogramovanie #1Metaprogramovanie #1
Metaprogramovanie #1Jano Suchal
 
Attributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active recordAttributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active record.toster
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love RubyBen Scheirman
 
Postobjektové programovanie v Ruby
Postobjektové programovanie v RubyPostobjektové programovanie v Ruby
Postobjektové programovanie v RubyJano Suchal
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everythingnoelrap
 
jRuby: The best of both worlds
jRuby: The best of both worldsjRuby: The best of both worlds
jRuby: The best of both worldsChristopher Spring
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosEdgar Suarez
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in RubyConFoo
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogrammingjoshbuddy
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairMark
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Wen-Tien Chang
 
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends旻琦 潘
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyVysakh Sreenivasan
 
Refactor like a boss
Refactor like a bossRefactor like a boss
Refactor like a bossgsterndale
 

Ähnlich wie A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles (20)

Metaprogramovanie #1
Metaprogramovanie #1Metaprogramovanie #1
Metaprogramovanie #1
 
Attributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active recordAttributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active record
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love Ruby
 
Postobjektové programovanie v Ruby
Postobjektové programovanie v RubyPostobjektové programovanie v Ruby
Postobjektové programovanie v Ruby
 
Ruby
RubyRuby
Ruby
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everything
 
jRuby: The best of both worlds
jRuby: The best of both worldsjRuby: The best of both worlds
jRuby: The best of both worlds
 
Dsl
DslDsl
Dsl
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutos
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
Language supports it
Language supports itLanguage supports it
Language supports it
 
Why ruby
Why rubyWhy ruby
Why ruby
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced Ruby
 
Refactor like a boss
Refactor like a bossRefactor like a boss
Refactor like a boss
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 

Mehr von Tchelinux

Do Zero ao YouTube em menos de 10 softwares livres - Vinícius Alves Hax - Tch...
Do Zero ao YouTube em menos de 10 softwares livres - Vinícius Alves Hax - Tch...Do Zero ao YouTube em menos de 10 softwares livres - Vinícius Alves Hax - Tch...
Do Zero ao YouTube em menos de 10 softwares livres - Vinícius Alves Hax - Tch...Tchelinux
 
Insegurança na Internet - Diego Luiz Silva da Costa - Tchelinux 2019 Rio Grande
Insegurança na Internet - Diego Luiz Silva da Costa - Tchelinux 2019 Rio GrandeInsegurança na Internet - Diego Luiz Silva da Costa - Tchelinux 2019 Rio Grande
Insegurança na Internet - Diego Luiz Silva da Costa - Tchelinux 2019 Rio GrandeTchelinux
 
Explorando Editores de Texto Open Source - Gabriel Prestes Ritta - Tchelinux ...
Explorando Editores de Texto Open Source - Gabriel Prestes Ritta - Tchelinux ...Explorando Editores de Texto Open Source - Gabriel Prestes Ritta - Tchelinux ...
Explorando Editores de Texto Open Source - Gabriel Prestes Ritta - Tchelinux ...Tchelinux
 
Desenvolvendo Jogos com PyGame - Jerônimo Medina Madruga - Tchelinux 2019 Rio...
Desenvolvendo Jogos com PyGame - Jerônimo Medina Madruga - Tchelinux 2019 Rio...Desenvolvendo Jogos com PyGame - Jerônimo Medina Madruga - Tchelinux 2019 Rio...
Desenvolvendo Jogos com PyGame - Jerônimo Medina Madruga - Tchelinux 2019 Rio...Tchelinux
 
Me formei. E agora? - Matheus Cezar - Tchelinux 2019 Rio Grande
Me formei. E agora? - Matheus Cezar - Tchelinux 2019 Rio GrandeMe formei. E agora? - Matheus Cezar - Tchelinux 2019 Rio Grande
Me formei. E agora? - Matheus Cezar - Tchelinux 2019 Rio GrandeTchelinux
 
APIs, REST e RESTful: O que os programadores precisam saber? - Marcos Echevar...
APIs, REST e RESTful: O que os programadores precisam saber? - Marcos Echevar...APIs, REST e RESTful: O que os programadores precisam saber? - Marcos Echevar...
APIs, REST e RESTful: O que os programadores precisam saber? - Marcos Echevar...Tchelinux
 
Shell Script: Seu melhor amigo na automatização de instalações e configuraçõe...
Shell Script: Seu melhor amigo na automatização de instalações e configuraçõe...Shell Script: Seu melhor amigo na automatização de instalações e configuraçõe...
Shell Script: Seu melhor amigo na automatização de instalações e configuraçõe...Tchelinux
 
WebRTC: Comunicação aberta em tempo real - Nelson Dutra Junior - Tchelinux 20...
WebRTC: Comunicação aberta em tempo real - Nelson Dutra Junior - Tchelinux 20...WebRTC: Comunicação aberta em tempo real - Nelson Dutra Junior - Tchelinux 20...
WebRTC: Comunicação aberta em tempo real - Nelson Dutra Junior - Tchelinux 20...Tchelinux
 
Introdução à programação funcional com Clojure - Victor Hechel Colares - Tche...
Introdução à programação funcional com Clojure - Victor Hechel Colares - Tche...Introdução à programação funcional com Clojure - Victor Hechel Colares - Tche...
Introdução à programação funcional com Clojure - Victor Hechel Colares - Tche...Tchelinux
 
Construindo um Data Warehouse - Vítor Resing Plentz - Tchelinux 2019 Rio Grande
Construindo um Data Warehouse - Vítor Resing Plentz - Tchelinux 2019 Rio GrandeConstruindo um Data Warehouse - Vítor Resing Plentz - Tchelinux 2019 Rio Grande
Construindo um Data Warehouse - Vítor Resing Plentz - Tchelinux 2019 Rio GrandeTchelinux
 
Bikeshedding - Márcio Josué Ramos Torres - Tchelinux 2019 Rio Grande
Bikeshedding - Márcio Josué Ramos Torres - Tchelinux 2019 Rio GrandeBikeshedding - Márcio Josué Ramos Torres - Tchelinux 2019 Rio Grande
Bikeshedding - Márcio Josué Ramos Torres - Tchelinux 2019 Rio GrandeTchelinux
 
Produção de textos com Latex - Samuel Francisco Ferrigo - Tchelinux Caxias do...
Produção de textos com Latex - Samuel Francisco Ferrigo - Tchelinux Caxias do...Produção de textos com Latex - Samuel Francisco Ferrigo - Tchelinux Caxias do...
Produção de textos com Latex - Samuel Francisco Ferrigo - Tchelinux Caxias do...Tchelinux
 
A tecnologia no futuro e nas mãos de quem ela estará - Jaqueline Trevizan, Ne...
A tecnologia no futuro e nas mãos de quem ela estará - Jaqueline Trevizan, Ne...A tecnologia no futuro e nas mãos de quem ela estará - Jaqueline Trevizan, Ne...
A tecnologia no futuro e nas mãos de quem ela estará - Jaqueline Trevizan, Ne...Tchelinux
 
oVirt uma solução de virtualização distribuída opensource - Daniel Lara - Tch...
oVirt uma solução de virtualização distribuída opensource - Daniel Lara - Tch...oVirt uma solução de virtualização distribuída opensource - Daniel Lara - Tch...
oVirt uma solução de virtualização distribuída opensource - Daniel Lara - Tch...Tchelinux
 
Sistemas Embarcados e Buildroot - Renato Severo - Tchelinux Caxias do Sul 2019
Sistemas Embarcados e Buildroot - Renato Severo - Tchelinux Caxias do Sul 2019Sistemas Embarcados e Buildroot - Renato Severo - Tchelinux Caxias do Sul 2019
Sistemas Embarcados e Buildroot - Renato Severo - Tchelinux Caxias do Sul 2019Tchelinux
 
Com que ônibus eu vou? Uma gentil introdução ao Python.
Com que ônibus eu vou? Uma gentil introdução ao Python.Com que ônibus eu vou? Uma gentil introdução ao Python.
Com que ônibus eu vou? Uma gentil introdução ao Python.Tchelinux
 
O TCC... um dia ele chega! (The beautiful and easy LaTeX way.
O TCC... um dia ele chega! (The beautiful and easy LaTeX way.O TCC... um dia ele chega! (The beautiful and easy LaTeX way.
O TCC... um dia ele chega! (The beautiful and easy LaTeX way.Tchelinux
 
Não deixe para testar depois o que você pode testar antes.
Não deixe para testar depois o que você pode testar antes. Não deixe para testar depois o que você pode testar antes.
Não deixe para testar depois o que você pode testar antes. Tchelinux
 
Desenvolvendo jogos com pygame
Desenvolvendo jogos com pygameDesenvolvendo jogos com pygame
Desenvolvendo jogos com pygameTchelinux
 
Essa câmera faz fotos muito boas, né?
Essa câmera faz fotos muito boas, né?Essa câmera faz fotos muito boas, né?
Essa câmera faz fotos muito boas, né?Tchelinux
 

Mehr von Tchelinux (20)

Do Zero ao YouTube em menos de 10 softwares livres - Vinícius Alves Hax - Tch...
Do Zero ao YouTube em menos de 10 softwares livres - Vinícius Alves Hax - Tch...Do Zero ao YouTube em menos de 10 softwares livres - Vinícius Alves Hax - Tch...
Do Zero ao YouTube em menos de 10 softwares livres - Vinícius Alves Hax - Tch...
 
Insegurança na Internet - Diego Luiz Silva da Costa - Tchelinux 2019 Rio Grande
Insegurança na Internet - Diego Luiz Silva da Costa - Tchelinux 2019 Rio GrandeInsegurança na Internet - Diego Luiz Silva da Costa - Tchelinux 2019 Rio Grande
Insegurança na Internet - Diego Luiz Silva da Costa - Tchelinux 2019 Rio Grande
 
Explorando Editores de Texto Open Source - Gabriel Prestes Ritta - Tchelinux ...
Explorando Editores de Texto Open Source - Gabriel Prestes Ritta - Tchelinux ...Explorando Editores de Texto Open Source - Gabriel Prestes Ritta - Tchelinux ...
Explorando Editores de Texto Open Source - Gabriel Prestes Ritta - Tchelinux ...
 
Desenvolvendo Jogos com PyGame - Jerônimo Medina Madruga - Tchelinux 2019 Rio...
Desenvolvendo Jogos com PyGame - Jerônimo Medina Madruga - Tchelinux 2019 Rio...Desenvolvendo Jogos com PyGame - Jerônimo Medina Madruga - Tchelinux 2019 Rio...
Desenvolvendo Jogos com PyGame - Jerônimo Medina Madruga - Tchelinux 2019 Rio...
 
Me formei. E agora? - Matheus Cezar - Tchelinux 2019 Rio Grande
Me formei. E agora? - Matheus Cezar - Tchelinux 2019 Rio GrandeMe formei. E agora? - Matheus Cezar - Tchelinux 2019 Rio Grande
Me formei. E agora? - Matheus Cezar - Tchelinux 2019 Rio Grande
 
APIs, REST e RESTful: O que os programadores precisam saber? - Marcos Echevar...
APIs, REST e RESTful: O que os programadores precisam saber? - Marcos Echevar...APIs, REST e RESTful: O que os programadores precisam saber? - Marcos Echevar...
APIs, REST e RESTful: O que os programadores precisam saber? - Marcos Echevar...
 
Shell Script: Seu melhor amigo na automatização de instalações e configuraçõe...
Shell Script: Seu melhor amigo na automatização de instalações e configuraçõe...Shell Script: Seu melhor amigo na automatização de instalações e configuraçõe...
Shell Script: Seu melhor amigo na automatização de instalações e configuraçõe...
 
WebRTC: Comunicação aberta em tempo real - Nelson Dutra Junior - Tchelinux 20...
WebRTC: Comunicação aberta em tempo real - Nelson Dutra Junior - Tchelinux 20...WebRTC: Comunicação aberta em tempo real - Nelson Dutra Junior - Tchelinux 20...
WebRTC: Comunicação aberta em tempo real - Nelson Dutra Junior - Tchelinux 20...
 
Introdução à programação funcional com Clojure - Victor Hechel Colares - Tche...
Introdução à programação funcional com Clojure - Victor Hechel Colares - Tche...Introdução à programação funcional com Clojure - Victor Hechel Colares - Tche...
Introdução à programação funcional com Clojure - Victor Hechel Colares - Tche...
 
Construindo um Data Warehouse - Vítor Resing Plentz - Tchelinux 2019 Rio Grande
Construindo um Data Warehouse - Vítor Resing Plentz - Tchelinux 2019 Rio GrandeConstruindo um Data Warehouse - Vítor Resing Plentz - Tchelinux 2019 Rio Grande
Construindo um Data Warehouse - Vítor Resing Plentz - Tchelinux 2019 Rio Grande
 
Bikeshedding - Márcio Josué Ramos Torres - Tchelinux 2019 Rio Grande
Bikeshedding - Márcio Josué Ramos Torres - Tchelinux 2019 Rio GrandeBikeshedding - Márcio Josué Ramos Torres - Tchelinux 2019 Rio Grande
Bikeshedding - Márcio Josué Ramos Torres - Tchelinux 2019 Rio Grande
 
Produção de textos com Latex - Samuel Francisco Ferrigo - Tchelinux Caxias do...
Produção de textos com Latex - Samuel Francisco Ferrigo - Tchelinux Caxias do...Produção de textos com Latex - Samuel Francisco Ferrigo - Tchelinux Caxias do...
Produção de textos com Latex - Samuel Francisco Ferrigo - Tchelinux Caxias do...
 
A tecnologia no futuro e nas mãos de quem ela estará - Jaqueline Trevizan, Ne...
A tecnologia no futuro e nas mãos de quem ela estará - Jaqueline Trevizan, Ne...A tecnologia no futuro e nas mãos de quem ela estará - Jaqueline Trevizan, Ne...
A tecnologia no futuro e nas mãos de quem ela estará - Jaqueline Trevizan, Ne...
 
oVirt uma solução de virtualização distribuída opensource - Daniel Lara - Tch...
oVirt uma solução de virtualização distribuída opensource - Daniel Lara - Tch...oVirt uma solução de virtualização distribuída opensource - Daniel Lara - Tch...
oVirt uma solução de virtualização distribuída opensource - Daniel Lara - Tch...
 
Sistemas Embarcados e Buildroot - Renato Severo - Tchelinux Caxias do Sul 2019
Sistemas Embarcados e Buildroot - Renato Severo - Tchelinux Caxias do Sul 2019Sistemas Embarcados e Buildroot - Renato Severo - Tchelinux Caxias do Sul 2019
Sistemas Embarcados e Buildroot - Renato Severo - Tchelinux Caxias do Sul 2019
 
Com que ônibus eu vou? Uma gentil introdução ao Python.
Com que ônibus eu vou? Uma gentil introdução ao Python.Com que ônibus eu vou? Uma gentil introdução ao Python.
Com que ônibus eu vou? Uma gentil introdução ao Python.
 
O TCC... um dia ele chega! (The beautiful and easy LaTeX way.
O TCC... um dia ele chega! (The beautiful and easy LaTeX way.O TCC... um dia ele chega! (The beautiful and easy LaTeX way.
O TCC... um dia ele chega! (The beautiful and easy LaTeX way.
 
Não deixe para testar depois o que você pode testar antes.
Não deixe para testar depois o que você pode testar antes. Não deixe para testar depois o que você pode testar antes.
Não deixe para testar depois o que você pode testar antes.
 
Desenvolvendo jogos com pygame
Desenvolvendo jogos com pygameDesenvolvendo jogos com pygame
Desenvolvendo jogos com pygame
 
Essa câmera faz fotos muito boas, né?
Essa câmera faz fotos muito boas, né?Essa câmera faz fotos muito boas, né?
Essa câmera faz fotos muito boas, né?
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Kürzlich hochgeladen (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles

  • 1.
  • 3. Clean, Elegant and Meaningful Syntax
  • 4. test_string = 'string for test' puts 'matched' if test_string.match 'string' files = Dir['*.txt'] for file in files file_ref = open file file_ref.each_line { |line| puts line.reverse.upcase } end
  • 5. Everything is an Object 10.times { puts “Hello World!” } “Hello World!”.methods
  • 6. Dynamic Typing, Duck Typing and Open Classes
  • 7. a_variable = 'a b c'.split(' ') #=> ['a','b','c'] a_variable = a_variable.join(' ') #=> 'a b c' def a_function object_par puts object_par.crazy_method end a_function [1,2,3] #=> error: undefined method 'crazy_method' for class Array class Array def crazy_method return 'crazy method for an array' end end a_function [1,2,3] #=> puts 'crazy method for an array'
  • 8. a_variable = 'a b c'.split(' ') #=> ['a','b','c'] a_variable = a_variable.join(' ') #=> 'a b c' def a_function object_par puts object_par.crazy_method end a_function [1,2,3] #=> error: undefined method 'crazy_method' for class Array class Array def crazy_method return 'crazy method for an array' end end a_function [1,2,3] #=> puts 'crazy method for an array'
  • 9. def a_function object_par puts object_par.crazy_method end some_obj = SomeClass.new a_function some_obj #=> error: undefined method 'crazy_method' for class SomeClass def some_obj.crazy_method return 'this is a crazy feature' end a_function some_obj #=> puts 'this is a crazy_feature'
  • 10. def a_function object_par puts object_par.crazy_method end some_obj = SomeClass.new a_function some_obj #=> error: undefined method 'crazy_method' for class SomeClass def some_obj.crazy_method return 'this is a crazy feature' end a_function some_obj #=> puts 'this is a crazy_feature'
  • 11. "if it walks like a duck and quacks like a duck, then it is a duck”
  • 13. def square an_array return an_array.map { |e| e*e } end lines_of_a_doc.each_with_index do |line,i| if i.even? then puts 'even line: #{line}' else puts 'odd line: ' + line end end
  • 14. [1,2,3,4].select { |e| e.even? } #=> [2,4] [1,2,3,4].collect { |e| e.even? } #=> [true,false,true,false] [1,2,3,4].inject(0) { |sum,e| sum += e } #=> 10
  • 15. def my_for n n.times { |n| yield(n) } end my_for 3 { |i| puts i } #=> 1 #=> 2 #=> 3
  • 17. class Books < Collection def initialize @books = SomeReader.new('some_file_with_books').get_books end include Enumerable def each @books.each { |book| yield(book) } end end Class Books now have map, select, inject, grep, find_all, include? and more
  • 19. require 'test/unit' class TestHtmlParser < Test::Unit::TestCase must “find all imgs” do parser = HtmlParser.new '<div class='a'> <br/> <img src='img1.jpg'>n <p><img src='img2.jpg'></body>' assert_equal parser.parse_imgs, ['img1.jpg','img2.jpg'] end end class HtmlParser def initialize html_doc @content = html_doc end def parse_imgs @content.scan(/imgs+src='(.+?)'/) end end
  • 20. Standard Library ● erb - .rhtml ● sockets ● threads ● html/xml parser ● ftp, http, imap, pop3, smtp ● tk ● pstore
  • 21. And Gems! $ gem install rails $ gem install rspec $ gem search twitter 13,007 gems and counting!
  • 22. Productivity and fun And that's it! Duda Dornelles dudassdornelles@gmail.com