Class: Codshit::Generator
- Inherits:
-
Object
- Object
- Codshit::Generator
show all
- Defined in:
- lib/codshit.rb
Constant Summary
collapse
- @@active_generator =
nil
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(&block) ⇒ Generator
Returns a new instance of Generator.
40
41
42
43
|
# File 'lib/codshit.rb', line 40
def initialize(&block)
@rules = {}
instance_eval(&block)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
49
50
51
|
# File 'lib/codshit.rb', line 49
def method_missing(method, *args, &block)
@rules[method] ||= Rule.new
end
|
Class Method Details
.active_generator ⇒ Object
36
37
38
|
# File 'lib/codshit.rb', line 36
def self.active_generator
@@active_generator
end
|
Instance Method Details
#[](rule) ⇒ Object
45
46
47
|
# File 'lib/codshit.rb', line 45
def [](rule)
@rules[rule]
end
|
#generate ⇒ Object
53
54
55
56
|
# File 'lib/codshit.rb', line 53
def generate
@@active_generator = self
@rules[:main].to_text
end
|