Class: Clit
- Inherits:
- BasicObject
- Defined in:
- lib/clit.rb
Overview
–
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
++
Defined Under Namespace
Classes: Theme
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil) ⇒ Clit
constructor
A new instance of Clit.
- #method_missing(id, *args, &block) ⇒ Object
- #respond_to_missing?(*args) ⇒ Boolean
- #theme(name = nil) ⇒ Object
Constructor Details
#initialize(name = nil) ⇒ Clit
Returns a new instance of Clit.
40 41 42 43 44 45 46 |
# File 'lib/clit.rb', line 40 def initialize (name = nil) if ::ENV['CLIT_THEME'] theme ::ENV['CLIT_THEME'].to_sym else theme :compatible end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id, *args, &block) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/clit.rb', line 56 def method_missing (id, *args, &block) if @theme.respond_to? id return @theme.__send__ id, *args, &block end super end |
Class Method Details
.define_theme(name, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/clit.rb', line 18 def self.define_theme (name, &block) if @themes[name] raise ArgumentError, "#{name} already exists" end @themes[name] = ::Class.new(::Clit::Theme, &block).instance.tap {|t| t.instance_variable_set :@name, name } end |
.theme(name) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/clit.rb', line 28 def self.theme (name) unless themes[name] require "clit/themes/#{name}" end unless themes[name] raise ::ArgumentError, "#{name} theme not found" end themes[name] end |
.themes ⇒ Object
14 15 16 |
# File 'lib/clit.rb', line 14 def self.themes @themes ||= {} end |
Instance Method Details
#respond_to_missing?(*args) ⇒ Boolean
52 53 54 |
# File 'lib/clit.rb', line 52 def respond_to_missing? (*args) @theme.respond_to?(*args) end |