This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Nothing | |
| def self.method_added meth | |
| p meth | |
| end | |
| def self.singleton_method_added meth | |
| p [meth, :sing] | |
| end | |
| def foo; end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def Coin █ Coin.new █ end | |
| class Coin | |
| def initialize &block | |
| toss &block if block_given? | |
| end | |
| def toss &block | |
| @toss = rand.round.zero? | |
| yield | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 10:15:26 <@zenspider> I wake up... and I come in here... and the FIRST thing I see is elliottcable being an obnoxious prick ... AGAIN. I don't know who lifted your ban, or why, but you sir are NOT a welcome element in this channel. | |
| 10:15:34 -!- Fullmoon [[email protected]] has quit [Client Quit] | |
| 10:15:59 -!- Symmetry- [[email protected]] has joined #ruby-lang | |
| 10:15:59 <@zenspider> I made it clear yesterday that I wasn't sure why your ban was lifted... but I let you stay, HOPING (stupidly) that maybe this time around you might have learned your lesson. | |
| 10:16:06 -!- Vardogr [[email protected]] has joined #ruby-lang | |
| 10:16:08 < elliottcable> … I'm helping people. And complaining about a channel, not this one, and then stopping doing so when I realized it may not be welcome to do so in here. | |
| 10:16:08 <@zenspider> it is pretty clear that you have not. | |
| 10:16:29 <@zenspider> so know this... I'll be back to reban you every time you show | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Foo | |
| # Both setter and accessor | |
| def on_paste | |
| if block_given? | |
| @on_paste = Proc.new # Implicit &block.to_proc | |
| else | |
| @on_paste | |
| end | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | File.open('/usr/share/dict/words').each_line do |line| | |
| if line =~ /^([a-fio]{3}){1,2}$/i | |
| l = line.chomp! | |
| l = l.gsub(/O/i, '0') | |
| l = l.gsub(/I/i, '1') | |
| # l = l.gsub(/L/i, '1') | |
| p "##{l.upcase} (#{line})" | |
| end | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 03:26:10 < elliottcable> Hey y'all | |
| 03:26:13 -!- ia [[email protected]] has quit [Client Quit] | |
| 03:26:25 < elliottcable> Trying to work on some code to manipulate methods; in the process, I need to deal with method_added. | |
| 03:27:25 < elliottcable> The problem is depending on whether the method is an instance or a singleton method, I have to use either the singleton method | |
| :method_added, or the singleton method :singleton_method_added | |
| 03:27:31 -!- ia [[email protected]] has joined #ruby | |
| 03:27:47 < elliottcable> my problem is I can't tell if currently we're working on a singleton or instance method | |
| 03:28:14 -!- TopoMorto [[email protected]] has quit [Remote closed the connection] | |
| 03:28:16 < elliottcable> is there some way to tell whether the current context is a normal class or a singleton class? | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Sing | |
| def singleton? | |
| self.test(FL_SINGLETON) | |
| end | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | my_object = Object.new | |
| another_object = Object.new | |
| def my_object.a_method | |
| self | |
| end | |
| my_object.a_method # => #<Object:0x33c0c> | |
| another_object.a_method | |
| # ~> -:9: undefined method `a_method' for #<Object:0x33bf8> (NoMethodError) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | if self.singleton? | |
| refine_singleton_method meth | |
| else | |
| refine_instance_method meth | |
| end | |
| if self.singleton?; refine_singleton_method meth | |
| else; refine_instance_method meth | |
| end | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | if abc | |
| class Gaz < Foo; end | |
| else | |
| class Gaz < Bar; end | |
| end | |
| class Gaz | |
| # whatever | |
| end |