Class: Synco::Directory

Inherits:
Controller show all
Defined in:
lib/synco/directory.rb

Overview

A specific directory which is relative to the root of a given server. Specific configuration details such as excludes and other options may be specified.

Instance Attribute Summary collapse

Attributes inherited from Controller

#events

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Controller

#abort!, build, #fire, #freeze, #on, #try

Constructor Details

#initialize(path, arguments: []) ⇒ Directory

Returns a new instance of Directory.



30
31
32
33
34
35
36
37
38
39
# File 'lib/synco/directory.rb', line 30

def initialize(path, arguments: [])
	if path.start_with?('/')
		raise AbsolutePathError.new("#{path} must be relative!")
	end
	
	super()
	
	@arguments = arguments
	@path = self.class.normalize(path)
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



42
43
44
# File 'lib/synco/directory.rb', line 42

def arguments
  @arguments
end

#pathObject (readonly)

Returns the value of attribute path.



41
42
43
# File 'lib/synco/directory.rb', line 41

def path
  @path
end

Class Method Details

.depth(path) ⇒ Object



56
57
58
# File 'lib/synco/directory.rb', line 56

def self.depth(path)
	path.count('/')
end

.normalize(path) ⇒ Object



52
53
54
# File 'lib/synco/directory.rb', line 52

def self.normalize(path)
	path.end_with?('/') ? path : path + '/'
end

Instance Method Details

#depthObject



44
45
46
# File 'lib/synco/directory.rb', line 44

def depth
	self.class.depth(@path)
end

#to_sObject



48
49
50
# File 'lib/synco/directory.rb', line 48

def to_s
	@path
end