Skip to content

Instantly share code, notes, and snippets.

@fkaa
Created June 4, 2014 20:23
Show Gist options
  • Select an option

  • Save fkaa/1da427d6a2370a66e42f to your computer and use it in GitHub Desktop.

Select an option

Save fkaa/1da427d6a2370a66e42f to your computer and use it in GitHub Desktop.
module Kaffeh
class Config
attr_accessor :title, :width, :height
def initialize(title = "Kaffeh", width = 600, height = 480)
@title = title
@width = width
@height = height
end
def to_s
return "[title: #{@title}, width: #{@width}, height: #{@height}]"
end
end
def self.config(&blk)
blk.call(Kaffeh::CONFIG)
end
CONFIG = Config.new
end
Kaffeh.config do |cfg|
cfg.title = "Foo!!"
end
puts Kaffeh::CONFIG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment