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
| case my_thing.is_a_flip? | |
| when abc | |
| blah.figgle.babbit | |
| when summat_else | |
| snizzle.bob | |
| when other_thingie | |
| sniff.sniff.sniff | |
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
| module Enumerable | |
| def inject_with_index(*args, &block) | |
| enum_for(:each_with_index).inject(*args, &block) | |
| end | |
| end | |
| spots = (data = surfline_data.to_hash)[:spot_name].split(',').inject_with_index(Hash.new) {|hash, (name, i)| hash[name] = data[:spot_url].split(',')[i] } |
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
| require 'attr_splat' | |
| class Class | |
| class self.singleton | |
| # We don't do this by default, just to be safe. It's perfectly acceptable, | |
| # as attr_*'s API is fully backwards compatible. | |
| # | |
| # Now every example below, attr_splat could safely be replaced with | |
| # attr_accessor | |
| alias_method :attr_accessor, :attr_splat |
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
| require 'attr_splat' | |
| class Class | |
| class self.singleton | |
| # We don't do this by default, just to be safe. It's perfectly acceptable, | |
| # as attr_*'s API is fully backwards compatible. | |
| # | |
| # Now every example below, attr_splat could safely be replaced with | |
| # attr_accessor | |
| alias_method :attr_accessor, :attr_splat |
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 Something | |
| a method... | |
| a method... | |
| a method... | |
| end 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 Foo | |
| def self.method_added(meth); puts "Foo#method_added: #{meth}"; end | |
| def self.singleton_method_added(meth); puts "Foo#singleton_method_added: #{meth}"; end | |
| # Singleton | |
| class << self | |
| def self.method_added(meth); puts "singleton#method_added: #{meth}"; end | |
| def self.singleton_method_added(meth); puts "singleton#singleton_method_added: #{meth}"; end | |
| # Metasingleton |
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 Something | |
| class << self | |
| def singleton_method_added meth | |
| puts "Self is currently #{self}, and we're defining #{meth}" | |
| end | |
| def a_method; end | |
| 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
| # require 'rubygems' | |
| # require 'evil' | |
| ($:.unshift '/Users/elliottcable/Code/refinery/lib').uniq! | |
| require 'refinery/core_ext/class' | |
| require 'refinery/core_ext/object' | |
| # class UnboundMethod | |
| # def rklass= klass | |
| # dmeth = nil | |
| # RubyInternal.critical { |
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 Object | |
| ## | |
| # Returns the singleton class for this object. | |
| # | |
| # @return Class this object's singleton class | |
| def singleton | |
| class<<self;self;end | |
| 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
| STDOUT.sync = true | |
| str = [ | |
| ['(o_o)', 6], | |
| ['(O_o)', 2], | |
| ['(<_<)', 1], | |
| ['(>_>)', 1], | |
| ['(<_<)', 2], | |
| ['(o_o)', 4], | |
| ['(>_>)', 3], | |
| [' (>_>', 3], |