Class: SimpleTemplater::DSL
- Inherits:
-
Object
- Object
- SimpleTemplater::DSL
- Includes:
- FileUtils
- Defined in:
- lib/simple-templater/dsl.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
Instance Method Summary collapse
- #file(name, &block) ⇒ Object
- #hook(&block) ⇒ Object
-
#initialize(generator) ⇒ DSL
constructor
A new instance of DSL.
- #make_executable(path) ⇒ Object
Methods included from FileUtils
Constructor Details
#initialize(generator) ⇒ DSL
Returns a new instance of DSL.
10 11 12 13 |
# File 'lib/simple-templater/dsl.rb', line 10 def initialize(generator) @generator = generator @context = generator.context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
9 10 11 |
# File 'lib/simple-templater/dsl.rb', line 9 def context @context end |
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
9 10 11 |
# File 'lib/simple-templater/dsl.rb', line 9 def generator @generator end |
Instance Method Details
#file(name, &block) ⇒ Object
19 20 21 |
# File 'lib/simple-templater/dsl.rb', line 19 def file(name, &block) File.open(name, "w", &block) end |
#hook(&block) ⇒ Object
23 24 25 |
# File 'lib/simple-templater/dsl.rb', line 23 def hook(&block) block.call(self.generator, self.context) end |
#make_executable(path) ⇒ Object
15 16 17 |
# File 'lib/simple-templater/dsl.rb', line 15 def make_executable(path) sh "chmod +x '#{path}'" end |