SlideShare una empresa de Scribd logo
1 de 21
THE METHODS METHOD
  AND ITS FRIENDS
   Method of the Month - Kevin Munc - @muncman
Class.methods.grep(/method/)


   => ["private_class_method", "method", "public_methods",
  "public_instance_methods", "method_defined?", "methods",
  "protected_instance_methods", "public_method_defined?",
       "singleton_methods", "private_instance_methods",
       "private_method_defined?", "protected_methods",
       "instance_method", "protected_method_defined?",
"public_class_method", "instance_methods", "private_methods"]
o = Object.new
         => #<Object:0x39cd94>


        o.methods.grep(/method/)
=> ["method", "public_methods", "methods",
"singleton_methods", "protected_methods",
           "private_methods"]
o.methods.grep(/method/).sort
=> ["method", "methods", "private_methods",
  "protected_methods", "public_methods",
           "singleton_methods"]
Method Methods
Object#method

Object#methods

Object#public_methods

Object#protected_methods

Object#private_methods

Object#singleton_methods
class Motm < String

 def first_method
  puts ‘First!’
 end

 def second_method
  puts ‘Second!’
 end

end
#methods &
      #public_methods

        motm = Motm.new
               => ""
    motm.public_methods(false)
=> ["first_method", "second_method"]
#methods &
     #public_methods


(motm.methods - "".methods).length
              => 2
Question for the Experts

                    # Why this difference?!?
motm.public_methods(true).length == motm.methods(true).length
                            => true
                            # but...
motm.public_methods(false).length == motm.methods(false).length
                       => false (2 vs. 0)
#protected_methods
   class Motm

    def protect_this
     puts 'Protected!'
    end

    protected :protect_this

   end
#protected_methods
      motm = Motm.new
             => ""


 motm.protected_methods(false)
      => ["protect_this"]
#private_methods
  class Motm
    def my_privates
     puts 'Private!'
    end
    private :my_privates
  end

  motm.private_methods(false)
      => ["my_privates"]
#singleton_methods
1.           2.




     3.           4.
#singleton_methods
1. module Crb      2.
    def brigade
     puts ‘This’
    end
   end 3.               4.
#singleton_methods
1. module Crb      2. class Motm
    def brigade         def self.short
     puts ‘This’         puts ‘is’
    end                 end
   end 3.             end     4.
#singleton_methods
1. module Crb            2. class Motm
    def brigade               def self.short
     puts ‘This’               puts ‘is’
    end                       end
   end 3. motm = Motm.new end       4.
           def motm.part_one
            puts ‘Spinal’
           end
#singleton_methods
1. module Crb            2. class Motm
    def brigade               def self.short
     puts ‘This’               puts ‘is’
    end                       end
   end 3. motm = Motm.new end       4. class << motm
          def motm.part_one            include Crb
           puts ‘Spinal’               def part_two
          end                            puts ‘Tap’
                                       end
                                      end
#singleton_methods
   Motm.singleton_methods(false)
           => ["short"]

      motm.singleton_methods
=> ["part_two", "brigade", "part_one"]

   motm.singleton_methods(false)
    => ["part_two", "part_one"]
#singleton_methods
  motm2 = Motm.new
 => #<Motm:0x578ce4>


motm2.singleton_methods
         => []
#method
meth = motm.method(:protect_this)
=> #<Method: MyClass#protect_this>


             meth.call
            Protected!
              => nil
QUESTIONS? ANSWERS?
                               Photo Sources


      http://www.library.usyd.edu.au/libraries/rare/medicine/barrough.html


           http://www.dnrmusicstore.com/graphics/HL%20guitar.JPG


              http://img1.jurko.net/wall/paper/method_man_2.jpg

Más contenido relacionado

Similar a The Methods Method and Its Friends (MOTM 2009.08)

Metaprogramming 101
Metaprogramming 101Metaprogramming 101
Metaprogramming 101Nando Vieira
 
Metaprogramming Rails
Metaprogramming RailsMetaprogramming Rails
Metaprogramming RailsJustus Eapen
 
Metaprogramming and Folly
Metaprogramming and FollyMetaprogramming and Folly
Metaprogramming and FollyHaseeb Qureshi
 
Securing Rails Keep Ruby Weird
Securing Rails Keep Ruby WeirdSecuring Rails Keep Ruby Weird
Securing Rails Keep Ruby WeirdMarcus Carey
 
Documenting from the Trenches
Documenting from the TrenchesDocumenting from the Trenches
Documenting from the TrenchesXavier Noria
 
Introduction to Ruby’s Reflection API
Introduction to Ruby’s Reflection APIIntroduction to Ruby’s Reflection API
Introduction to Ruby’s Reflection APINiranjan Sarade
 
Benchmarking Perl Lightning Talk (NPW 2007)
Benchmarking Perl Lightning Talk (NPW 2007)Benchmarking Perl Lightning Talk (NPW 2007)
Benchmarking Perl Lightning Talk (NPW 2007)brian d foy
 
Metaprogramming code-that-writes-code
Metaprogramming code-that-writes-codeMetaprogramming code-that-writes-code
Metaprogramming code-that-writes-codeorga shih
 
Active Support Core Extensions (1)
Active Support Core Extensions (1)Active Support Core Extensions (1)
Active Support Core Extensions (1)RORLAB
 
Lightning talk
Lightning talkLightning talk
Lightning talknpalaniuk
 
The Black Magic of Ruby Metaprogramming
The Black Magic of Ruby MetaprogrammingThe Black Magic of Ruby Metaprogramming
The Black Magic of Ruby Metaprogrammingitnig
 
Mock it right! A beginner’s guide to world of tests and mocks, Maciej Polańczyk
Mock it right! A beginner’s guide to world of tests and mocks, Maciej PolańczykMock it right! A beginner’s guide to world of tests and mocks, Maciej Polańczyk
Mock it right! A beginner’s guide to world of tests and mocks, Maciej PolańczykPôle Systematic Paris-Region
 
Ruby object model at the Ruby drink-up of Sophia, January 2013
Ruby object model at the Ruby drink-up of Sophia, January 2013Ruby object model at the Ruby drink-up of Sophia, January 2013
Ruby object model at the Ruby drink-up of Sophia, January 2013rivierarb
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby MetaprogrammingNando Vieira
 

Similar a The Methods Method and Its Friends (MOTM 2009.08) (20)

Dsl
DslDsl
Dsl
 
Metaprogramming 101
Metaprogramming 101Metaprogramming 101
Metaprogramming 101
 
Deciphering the Ruby Object Model
Deciphering the Ruby Object ModelDeciphering the Ruby Object Model
Deciphering the Ruby Object Model
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
 
Ruby tricks2
Ruby tricks2Ruby tricks2
Ruby tricks2
 
Metaprogramming Rails
Metaprogramming RailsMetaprogramming Rails
Metaprogramming Rails
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
 
Metaprogramming and Folly
Metaprogramming and FollyMetaprogramming and Folly
Metaprogramming and Folly
 
Securing Rails Keep Ruby Weird
Securing Rails Keep Ruby WeirdSecuring Rails Keep Ruby Weird
Securing Rails Keep Ruby Weird
 
Documenting from the Trenches
Documenting from the TrenchesDocumenting from the Trenches
Documenting from the Trenches
 
Introduction to Ruby’s Reflection API
Introduction to Ruby’s Reflection APIIntroduction to Ruby’s Reflection API
Introduction to Ruby’s Reflection API
 
Benchmarking Perl Lightning Talk (NPW 2007)
Benchmarking Perl Lightning Talk (NPW 2007)Benchmarking Perl Lightning Talk (NPW 2007)
Benchmarking Perl Lightning Talk (NPW 2007)
 
Metaprogramming code-that-writes-code
Metaprogramming code-that-writes-codeMetaprogramming code-that-writes-code
Metaprogramming code-that-writes-code
 
Active Support Core Extensions (1)
Active Support Core Extensions (1)Active Support Core Extensions (1)
Active Support Core Extensions (1)
 
Lightning talk
Lightning talkLightning talk
Lightning talk
 
The Black Magic of Ruby Metaprogramming
The Black Magic of Ruby MetaprogrammingThe Black Magic of Ruby Metaprogramming
The Black Magic of Ruby Metaprogramming
 
Mock it right! A beginner’s guide to world of tests and mocks, Maciej Polańczyk
Mock it right! A beginner’s guide to world of tests and mocks, Maciej PolańczykMock it right! A beginner’s guide to world of tests and mocks, Maciej Polańczyk
Mock it right! A beginner’s guide to world of tests and mocks, Maciej Polańczyk
 
Ruby object model at the Ruby drink-up of Sophia, January 2013
Ruby object model at the Ruby drink-up of Sophia, January 2013Ruby object model at the Ruby drink-up of Sophia, January 2013
Ruby object model at the Ruby drink-up of Sophia, January 2013
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby Metaprogramming
 
Steady with ruby
Steady with rubySteady with ruby
Steady with ruby
 

Más de Kevin Munc

Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Kevin Munc
 
NaN, Zero, & Infinities
NaN, Zero, & InfinitiesNaN, Zero, & Infinities
NaN, Zero, & InfinitiesKevin Munc
 
Basic Scheduling with setTimeout & setInterval
Basic Scheduling with setTimeout & setIntervalBasic Scheduling with setTimeout & setInterval
Basic Scheduling with setTimeout & setIntervalKevin Munc
 
Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’
Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’
Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’Kevin Munc
 
Number Conversions (MOTM 2010.12)
Number Conversions (MOTM 2010.12)Number Conversions (MOTM 2010.12)
Number Conversions (MOTM 2010.12)Kevin Munc
 
Percent Literals (MOTM 2010.09)
Percent Literals (MOTM 2010.09)Percent Literals (MOTM 2010.09)
Percent Literals (MOTM 2010.09)Kevin Munc
 
cycle (MOTM 2010.07)
cycle (MOTM 2010.07)cycle (MOTM 2010.07)
cycle (MOTM 2010.07)Kevin Munc
 
empty?, nil?, blank?, & present? (MOTM 2010.05)
empty?, nil?, blank?, & present? (MOTM 2010.05)empty?, nil?, blank?, & present? (MOTM 2010.05)
empty?, nil?, blank?, & present? (MOTM 2010.05)Kevin Munc
 
Take & Drop (MOTM 2010.04)
Take & Drop (MOTM 2010.04)Take & Drop (MOTM 2010.04)
Take & Drop (MOTM 2010.04)Kevin Munc
 
Helpers (MOTM 2010.03)
Helpers (MOTM 2010.03)Helpers (MOTM 2010.03)
Helpers (MOTM 2010.03)Kevin Munc
 
Grouping (MOTM 2010.02)
Grouping (MOTM 2010.02)Grouping (MOTM 2010.02)
Grouping (MOTM 2010.02)Kevin Munc
 
Removing Methods (MOTM 2010.01)
Removing Methods (MOTM 2010.01)Removing Methods (MOTM 2010.01)
Removing Methods (MOTM 2010.01)Kevin Munc
 
gsub (MOTM 2009.09)
gsub (MOTM 2009.09)gsub (MOTM 2009.09)
gsub (MOTM 2009.09)Kevin Munc
 
Ruby's String Slicing (MOTM 2009.07)
Ruby's String Slicing (MOTM 2009.07)Ruby's String Slicing (MOTM 2009.07)
Ruby's String Slicing (MOTM 2009.07)Kevin Munc
 

Más de Kevin Munc (15)

Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013
 
NaN, Zero, & Infinities
NaN, Zero, & InfinitiesNaN, Zero, & Infinities
NaN, Zero, & Infinities
 
Basic Scheduling with setTimeout & setInterval
Basic Scheduling with setTimeout & setIntervalBasic Scheduling with setTimeout & setInterval
Basic Scheduling with setTimeout & setInterval
 
Shellwords
ShellwordsShellwords
Shellwords
 
Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’
Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’
Apples & Oranges? Adventures in Equality Comparison & one of the ‘Bad Parts’
 
Number Conversions (MOTM 2010.12)
Number Conversions (MOTM 2010.12)Number Conversions (MOTM 2010.12)
Number Conversions (MOTM 2010.12)
 
Percent Literals (MOTM 2010.09)
Percent Literals (MOTM 2010.09)Percent Literals (MOTM 2010.09)
Percent Literals (MOTM 2010.09)
 
cycle (MOTM 2010.07)
cycle (MOTM 2010.07)cycle (MOTM 2010.07)
cycle (MOTM 2010.07)
 
empty?, nil?, blank?, & present? (MOTM 2010.05)
empty?, nil?, blank?, & present? (MOTM 2010.05)empty?, nil?, blank?, & present? (MOTM 2010.05)
empty?, nil?, blank?, & present? (MOTM 2010.05)
 
Take & Drop (MOTM 2010.04)
Take & Drop (MOTM 2010.04)Take & Drop (MOTM 2010.04)
Take & Drop (MOTM 2010.04)
 
Helpers (MOTM 2010.03)
Helpers (MOTM 2010.03)Helpers (MOTM 2010.03)
Helpers (MOTM 2010.03)
 
Grouping (MOTM 2010.02)
Grouping (MOTM 2010.02)Grouping (MOTM 2010.02)
Grouping (MOTM 2010.02)
 
Removing Methods (MOTM 2010.01)
Removing Methods (MOTM 2010.01)Removing Methods (MOTM 2010.01)
Removing Methods (MOTM 2010.01)
 
gsub (MOTM 2009.09)
gsub (MOTM 2009.09)gsub (MOTM 2009.09)
gsub (MOTM 2009.09)
 
Ruby's String Slicing (MOTM 2009.07)
Ruby's String Slicing (MOTM 2009.07)Ruby's String Slicing (MOTM 2009.07)
Ruby's String Slicing (MOTM 2009.07)
 

Último

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
🐬 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
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Último (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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 ...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

The Methods Method and Its Friends (MOTM 2009.08)

Notas del editor

  1. Continuing quest to lower the bar and discuss beginner-level topics in bite-sized chunks. irb Used methods method to choose a new MOTM...
  2. Too Many! Instance methods, not Class methods! (The Method of Physick is the first textbook on medicine published in English)
  3. Grep! Array of method names you can call on the instance.
  4. Sort!
  5. Though not in that order...
  6. Starting with this class... Note 2 methods defined *at this level*.
  7. Synonymous (more or less). Array of accessible method names you can call. With false! Maybe show &amp;#x2018;true&amp;#x2019; result in irb here.
  8. Subtraction instead of &amp;#x2018;false&amp;#x2019;!
  9. Supposed to be synonymous, according to PickAxe... (Ruby 1.8.6, at least.) methods(false) acts like singleton_methods(false). Don&amp;#x2019;t delay too long - maybe for discussion at the bar later... irb demonstration? def motm.another_method puts &amp;#x2018;Another!&amp;#x2019; end
  10. Note: didn&amp;#x2019;t have to pass false to protected_methods since String has none.
  11. Note: now have to pass false.
  12. Don&amp;#x2019;t rush this slide (LOTS!). http://www.rubyist.net/~slagell/ruby/singletonmethods.html &amp;#x201C;A method given only to a single object is called a singleton method.&amp;#x201D;
  13. Don&amp;#x2019;t rush this slide (LOTS!). http://www.rubyist.net/~slagell/ruby/singletonmethods.html &amp;#x201C;A method given only to a single object is called a singleton method.&amp;#x201D;
  14. Don&amp;#x2019;t rush this slide (LOTS!). http://www.rubyist.net/~slagell/ruby/singletonmethods.html &amp;#x201C;A method given only to a single object is called a singleton method.&amp;#x201D;
  15. Don&amp;#x2019;t rush this slide (LOTS!). http://www.rubyist.net/~slagell/ruby/singletonmethods.html &amp;#x201C;A method given only to a single object is called a singleton method.&amp;#x201D;
  16. These methods are only on this *instance*. http://osdir.com/ml/lang.ruby.core/2005-04/msg00006.html File is a good class for testing this stuff. singleton_methods(true) ~ &amp;#x201C;singleton_and_inherited_methods&amp;#x201D; &quot;singleton_methods(true)&quot; means &quot;singleton methods on this object or, if the object is a Class, this object and its ancestral classes.&quot;
  17. No methods on this *instance*.
  18. Different than the other methods covered... (no array).
  19. ri Object#methods http://www.ruby-doc.org/