Class: Cotta::DirectoryContent
- Inherits:
-
Object
- Object
- Cotta::DirectoryContent
- Defined in:
- lib/cotta/impl/in_memory_system.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#stat ⇒ Object
readonly
Returns the value of attribute stat.
Instance Method Summary collapse
- #add(content) ⇒ Object
- #copy_to_dir(system, parent_dir, target_dir) ⇒ Object
- #delete(name) ⇒ Object
- #directory? ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(name) ⇒ DirectoryContent
constructor
A new instance of DirectoryContent.
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
#children ⇒ Object (readonly)
Returns the value of attribute children.
195 196 197 |
# File 'lib/cotta/impl/in_memory_system.rb', line 195 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
195 196 197 |
# File 'lib/cotta/impl/in_memory_system.rb', line 195 def name @name end |
#stat ⇒ Object (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
207 208 209 |
# File 'lib/cotta/impl/in_memory_system.rb', line 207 def directory? return true end |
#file? ⇒ Boolean
203 204 205 |
# File 'lib/cotta/impl/in_memory_system.rb', line 203 def file? return false end |