Class: Sk::Skeleton

Inherits:
Object
  • Object
show all
Defined in:
lib/sk/skeleton.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject

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, options={})
  FileUtils.touch name
end