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.



15
16
17
18
19
20
21
22
23
24
# File 'lib/synco/directory.rb', line 15

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.



27
28
29
# File 'lib/synco/directory.rb', line 27

def arguments
  @arguments
end

#pathObject (readonly)

Returns the value of attribute path.



26
27
28
# File 'lib/synco/directory.rb', line 26

def path
  @path
end

Class Method Details

.depth(path) ⇒ Object



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

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

.normalize(path) ⇒ Object



37
38
39
# File 'lib/synco/directory.rb', line 37

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

Instance Method Details

#depthObject



29
30
31
# File 'lib/synco/directory.rb', line 29

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

#to_sObject



33
34
35
# File 'lib/synco/directory.rb', line 33

def to_s
  @path
end