Class: Cotta::FileContent

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) ⇒ FileContent

Returns a new instance of FileContent.



230
231
232
233
234
# File 'lib/cotta/impl/in_memory_system.rb', line 230

def initialize(name)
  @name = name
  @content = ''
  @stat = ContentStat.new(self)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



227
228
229
# File 'lib/cotta/impl/in_memory_system.rb', line 227

def content
  @content
end

#nameObject (readonly)

Returns the value of attribute name.



227
228
229
# File 'lib/cotta/impl/in_memory_system.rb', line 227

def name
  @name
end

#statObject (readonly)

Returns the value of attribute stat.



227
228
229
# File 'lib/cotta/impl/in_memory_system.rb', line 227

def stat
  @stat
end

Instance Method Details

#copy_to_dir(system, parent_dir, target_dir) ⇒ Object



248
249
250
251
252
# File 'lib/cotta/impl/in_memory_system.rb', line 248

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

#directory?Boolean

Returns:

  • (Boolean)


240
241
242
# File 'lib/cotta/impl/in_memory_system.rb', line 240

def directory?
  return false
end

#file?Boolean

Returns:

  • (Boolean)


236
237
238
# File 'lib/cotta/impl/in_memory_system.rb', line 236

def file?
  return true
end

#sizeObject



244
245
246
# File 'lib/cotta/impl/in_memory_system.rb', line 244

def size
  content.size
end

#touchObject



254
255
256
# File 'lib/cotta/impl/in_memory_system.rb', line 254

def touch
  @stat.touch
end