class MemFs::Fake::File::Content
Attributes
Public Class Methods
Source
# File lib/memfs/fake/file/content.rb, line 12 def initialize(obj = '') @string = obj.to_s.dup @pos = 0 __setobj__ @string end
Public Instance Methods
Source
# File lib/memfs/fake/file/content.rb, line 19 def puts(*strings) strings.each do |str| @string << str next if str.end_with?($/) @string << $/ end end
Source
# File lib/memfs/fake/file/content.rb, line 27 def read(length = nil, buffer = '') length ||= @string.length - @pos buffer.replace @string[@pos, length] @pos += buffer.bytesize buffer.empty? ? nil : buffer end
Source
# File lib/memfs/fake/file/content.rb, line 34 def truncate(length) @string.replace @string[0, length] end
Source
# File lib/memfs/fake/file/content.rb, line 42 def write(string) text = string.to_s @string << text text.size end