Class: Sk::Skeleton
- Inherits:
-
Object
- Object
- Sk::Skeleton
- Defined in:
- lib/sk/skeleton.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #dir(name, &block) ⇒ Object
- #file(name, options = {}) ⇒ Object (also: #touch)
-
#initialize(name, &block) ⇒ Skeleton
constructor
A new instance of Skeleton.
Constructor Details
#initialize(name, &block) ⇒ Skeleton
Returns a new instance of Skeleton.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sk/skeleton.rb', line 10 def initialize(name, &block) @name = name # check if dir already exists! FileUtils.mkdir(@name) FileUtils.cd(@name) block.call self # go back! FileUtils.cd('..') end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/sk/skeleton.rb', line 8 def name @name end |
Instance Method Details
#dir(name, &block) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/sk/skeleton.rb', line 29 def dir(name, &block) FileUtils.mkdir(name) FileUtils.cd(name) block.call if block FileUtils.cd('..') end |
#file(name, options = {}) ⇒ Object Also known as: touch
23 24 25 |
# File 'lib/sk/skeleton.rb', line 23 def file(name, ={}) FileUtils.touch name end |