Class: Jorm::Folder

Inherits:
Object
  • Object
show all
Defined in:
lib/jorm/folder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (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

Returns:

  • (Boolean)


24
25
26
# File 'lib/jorm/folder.rb', line 24

def already_normalized?
  Jorm.already_normalized? path.to_s
end

#can_normalize?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/jorm/folder.rb', line 12

def can_normalize?
  Jorm.can_normalize? path.to_s
end

#is_folder?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


16
17
18
# File 'lib/jorm/folder.rb', line 16

def should_normalize?
  is_folder? && can_normalize? && !already_normalized?
end