Skip to content

Instantly share code, notes, and snippets.

@shereefb
Created October 10, 2012 00:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shereefb/3862388 to your computer and use it in GitHub Desktop.
Save shereefb/3862388 to your computer and use it in GitHub Desktop.
Scopes breakout
class Cookie
MAX_CHIPS = 100
end
class PeanutButterCookie < Cookie
MAX_CHIPS = 100000
end
my_pbc = PeanutButterCookie.new
puts PeanutButterCookie::MAX_CHIPS
# class ShereefArray < Array
# def my_each(&block)
# self.each do |x|
# puts "about to do something to an element"
# block.call(x)
# end
#
# end
#
# def self.blue
# puts "red"
# end
# end
#
# my_array = ShereefArray.new
# my_array.my_each do |x|
# puts x
# end
# Array.blue
# class CookieJar
# MAX_COOKIES = 100
#
# def initialize
# @cookies = []
# end
#
# def add_cookie
# if @cookies.length >= @@MAC_COOKIES
# raise "Sorry, max reached. No more sugar for you"
# end
#
# @cookies << Cookie.new
# end
# end
#
# class Cookie
# # attr_accessor :chips
#
# def self.definition
# "Invented in #{@@year_invented}"
# end
#
# def initialize
# @chips = 100
# end
#
# def number_of_chips
# counter = 0
#
# @chips
# end
#
# def invented_in(year)
# "Invented in #{@@year_invented}"
# end
# end
#
# CookieJar::MAX_COOKIES
# puts Cookie.definition
# my_cookie = Cookie.new
# puts my_cookie.invented_in(10000)
# puts my_cookie.number_of_chips
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment