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.
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
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
42 43 44 |
# File 'lib/synco/directory.rb', line 42 def arguments @arguments end |
#path ⇒ Object (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
#depth ⇒ Object
44 45 46 |
# File 'lib/synco/directory.rb', line 44 def depth self.class.depth(@path) end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/synco/directory.rb', line 48 def to_s @path end |