Class: Synco::Directory
- Inherits:
-
Controller
- Object
- Controller
- Synco::Directory
- 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
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from Controller
Class Method Summary collapse
Instance Method Summary collapse
- #depth ⇒ Object
-
#initialize(path, arguments: []) ⇒ Directory
constructor
A new instance of Directory.
- #to_s ⇒ Object
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
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
27 28 29 |
# File 'lib/synco/directory.rb', line 27 def arguments @arguments end |
#path ⇒ Object (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
#depth ⇒ Object
29 30 31 |
# File 'lib/synco/directory.rb', line 29 def depth self.class.depth(@path) end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/synco/directory.rb', line 33 def to_s @path end |