Class: Cotta::DirectoryContent

Inherits:
Object
  • Object
show all
Defined in:
lib/cotta/impl/in_memory_system.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ DirectoryContent

Returns a new instance of DirectoryContent.



197
198
199
200
201
# File 'lib/cotta/impl/in_memory_system.rb', line 197

def initialize(name)
  @name = name
  @children = Array.new
  @stat = ContentStat.new(self)
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



195
196
197
# File 'lib/cotta/impl/in_memory_system.rb', line 195

def children
  @children
end

#nameObject (readonly)

Returns the value of attribute name.



195
196
197
# File 'lib/cotta/impl/in_memory_system.rb', line 195

def name
  @name
end

#statObject (readonly)

Returns the value of attribute stat.



195
196
197
# File 'lib/cotta/impl/in_memory_system.rb', line 195

def stat
  @stat
end

Instance Method Details

#add(content) ⇒ Object



211
212
213
# File 'lib/cotta/impl/in_memory_system.rb', line 211

def add(content)
  @children.push(content)
end

#copy_to_dir(system, parent_dir, target_dir) ⇒ Object



219
220
221
222
223
# File 'lib/cotta/impl/in_memory_system.rb', line 219

def copy_to_dir(system, parent_dir, target_dir)
  source_path = parent_dir.join(name)
  target_path = target_dir.join(name)
  system.copy_dir(source_path, target_path)
end

#delete(name) ⇒ Object



215
216
217
# File 'lib/cotta/impl/in_memory_system.rb', line 215

def delete(name)
  @children.delete_if {|file_content| file_content.name == name}
end

#directory?Boolean

Returns:

  • (Boolean)


207
208
209
# File 'lib/cotta/impl/in_memory_system.rb', line 207

def directory?
  return true
end

#file?Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/cotta/impl/in_memory_system.rb', line 203

def file?
  return false
end