Your SlideShare is downloading. ×
A ciência por trás do Ruby
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

A ciência por trás do Ruby

844

Published on

Published in: Technology, Lifestyle
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
844
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
1
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. A ciência por trás do Ruby Carlos Brando www.nomedojogo.com
    • 2. BETA A ciência por trás do Ruby Carlos Brando www.nomedojogo.com
    • 3. BEGIN WHILE 1=1 DO BEGIN outtext("Hello World!"); outimage; END; END;
    • 4. Simula
    • 5. template<typename _Tp, typename _Sequence = deque<_Tp> > class stack { // concept requirements typedef typename _Sequence::value_type _Sequence_value_type; __glibcxx_class_requires(_Tp, _SGIAssignableConcept) __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept) __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) }
    • 6. template<typename _Tp, typename _Sequence = deque<_Tp> > class stack { // concept requirements typedef typename _Sequence::value_type _Sequence_value_type; __glibcxx_class_requires(_Tp, _SGIAssignableConcept) __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept) __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) } final class Pair<A extends Comparable<A> & Cloneable<A>, B extends Comparable<B> & Cloneable<B>> implements Comparable<Pair<A,B>>, Cloneable<Pair<A,B>> { }
    • 7. http://blog.caelum.com.br/2006/10/14/como-nao-aprender-orientacao-a-objetos-heranca/
    • 8. Ruby é uma linguagem orientada a objetos
    • 9. Ruby é uma verdadeira linguagem orientada a objetos
    • 10. Objetos Estado + Comportamento
    • 11. class Dog def initialize(breed, name) @breed = breed @name = name end def eat # ... end def sleep # ... end end
    • 12. rex = Dog.new("bulldog", "Rex")
    • 13. rex = Dog.new("bulldog", "Rex") rex @breed: “bulldog” @name: “Rex” sleep() eat()
    • 14. rex = Dog.new("bulldog", "Rex") Dog rex @breed sleep @name eat tabela de métodos
    • 15. rex = Dog.new("bulldog", "Rex") Dog rex @breed sleep @name eat class
    • 16. fido = Dog.new("vira-lata", "Fido") fido @breed Dog @name class sleep eat rex @breed @name class
    • 17. self
    • 18. self É o centro do seu código Ruby • Onde as variáveis de instância são encontradas Ex: @var • O receiver padrão para as chamadas de métodos Ex: eat(‘hot dog’)
    • 19. self Apenas duas coisas podem mudar self • Uma chamada de método • A definição de uma classe/módulo
    • 20. dog = "rex" puts dog.upcase puts dog.object_id def dog.speak "Auau" end puts dog.speak
    • 21. self String dog @value: “rex” downcase upcase class
    • 22. Object dup object_id parent self String dog @value: “rex” downcase upcase class parent
    • 23. Object dup object_id parent String downcase upcase parent self ???? dog @value: “rex” speak class parent
    • 24. Object Singleton Class dup object_id • Eigenclass, Metaclass, Ghost Class, Virtual Class, ... parent • Uma classe comum, mas String escondida downcase upcase • Apenas uma por objeto parent self ???? dog @value: “rex” speak class parent
    • 25. self Apenas duas coisas podem mudar self Uma chamada de método • A definição de uma classe/módulo
    • 26. # código class Dog # código end # código
    • 27. class Dog def speak “Miau” end def self.speak "Auau" end end
    • 28. Object dup object_id parent self Dog parent dog @name: “rex” metodos class
    • 29. Object Object dup dup object_id object_id parent parent self Dog Class parent parent dog @name: “rex” metodos class class class
    • 30. Object Object dup Class object_id parent parent class self Dog ???? parent parent dog @value: “rex” metodos speak class class
    • 31. Tudo que você precisa se lembrar é... Variáveis de instância: localizadas na variável self Métodos: localizados na classe da variável self
    • 32. Mas ainda não terminamos...
    • 33. class Dog class << self def speak end end end
    • 34. public class Cachorro { private static int patas = ""; public static int getPatas() { return patas; } }
    • 35. class Cachorro @patas = 4 def getPatas @patas end end
    • 36. Mas ainda não terminamos...
    • 37. class B < A end
    • 38. Só mais uma coisa importante...
    • 39. include vs extend
    • 40. Object dup object_id parent Minha Classe parent downcase upcase
    • 41. Object dup object_id ???? MeuMódulo parent metodo tabela de métodos MinhaClasse parent meu_metodo
    • 42. Tudo isso fez sentido para você?
    • 43. @carlosbrando

    ×