Class: Jorm::Folder
- Inherits:
-
Object
- Object
- Jorm::Folder
- Defined in:
- lib/jorm/folder.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #already_normalized? ⇒ Boolean
- #can_normalize? ⇒ Boolean
-
#initialize(path) ⇒ Folder
constructor
A new instance of Folder.
- #is_folder? ⇒ Boolean
- #normalize! ⇒ Object
- #should_normalize? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ Folder
Returns a new instance of Folder.
8 9 10 |
# File 'lib/jorm/folder.rb', line 8 def initialize path @path = ::Pathname.new path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/jorm/folder.rb', line 6 def path @path end |
Instance Method Details
#already_normalized? ⇒ Boolean
24 25 26 |
# File 'lib/jorm/folder.rb', line 24 def already_normalized? Jorm.already_normalized? path.to_s end |
#can_normalize? ⇒ Boolean
12 13 14 |
# File 'lib/jorm/folder.rb', line 12 def can_normalize? Jorm.can_normalize? path.to_s end |
#is_folder? ⇒ Boolean
20 21 22 |
# File 'lib/jorm/folder.rb', line 20 def is_folder? path.directory? end |
#normalize! ⇒ Object
28 29 30 31 |
# File 'lib/jorm/folder.rb', line 28 def normalize! return unless should_normalize? FileUtils.mv path, Jorm.normalize_id(path.to_s) end |
#should_normalize? ⇒ Boolean
16 17 18 |
# File 'lib/jorm/folder.rb', line 16 def should_normalize? is_folder? && can_normalize? && !already_normalized? end |