Class: FSSM::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/fssm/path.rb

Instance Method Summary collapse

Constructor Details

#initialize(path = nil, glob = nil, options = {}, &block) ⇒ Path

Returns a new instance of Path.



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fssm/path.rb', line 2

def initialize(path=nil, glob=nil, options={}, &block)
  @options = options
  set_path(path || '.')
  set_glob(glob || '**/*')
  init_callbacks

  if block_given?
    if block.arity == 1
      block.call(self)
    else
      self.instance_eval(&block)
    end
  end
end

Instance Method Details

#create(*args, &block) ⇒ Object



30
31
32
# File 'lib/fssm/path.rb', line 30

def create(*args, &block)
  callback_action(:create, (block_given? ? block : args))
end

#delete(*args, &block) ⇒ Object



38
39
40
# File 'lib/fssm/path.rb', line 38

def delete(*args, &block)
  callback_action(:delete, (block_given? ? block : args))
end

#glob(value = nil) ⇒ Object



25
26
27
28
# File 'lib/fssm/path.rb', line 25

def glob(value=nil)
  return @glob if value.nil?
  set_glob(value)
end

#to_pathnameObject



21
22
23
# File 'lib/fssm/path.rb', line 21

def to_pathname
  @path
end

#to_sObject



17
18
19
# File 'lib/fssm/path.rb', line 17

def to_s
  @path.to_s
end

#update(*args, &block) ⇒ Object



34
35
36
# File 'lib/fssm/path.rb', line 34

def update(*args, &block)
  callback_action(:update, (block_given? ? block : args))
end