Class: ActiveRecordCopy::TempBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord-copy/temp_buffer.rb

Instance Method Summary collapse

Constructor Details

#initializeTempBuffer

Returns a new instance of TempBuffer.



3
4
5
# File 'lib/activerecord-copy/temp_buffer.rb', line 3

def initialize
  @st = ''.force_encoding(ASCII_8BIT_ENCODING)
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/activerecord-copy/temp_buffer.rb', line 34

def empty?
  @st.empty?
end

#posObject



26
27
28
# File 'lib/activerecord-copy/temp_buffer.rb', line 26

def pos
  @st.bytesize
end

#readObject



22
23
24
# File 'lib/activerecord-copy/temp_buffer.rb', line 22

def read
  @st
end

#reopenObject



18
19
20
# File 'lib/activerecord-copy/temp_buffer.rb', line 18

def reopen
  @st = ''
end

#rewindObject



15
16
# File 'lib/activerecord-copy/temp_buffer.rb', line 15

def rewind
end

#sizeObject



7
8
9
# File 'lib/activerecord-copy/temp_buffer.rb', line 7

def size
  @st.bytesize
end

#stringObject



30
31
32
# File 'lib/activerecord-copy/temp_buffer.rb', line 30

def string
  @st
end

#write(st) ⇒ Object



11
12
13
# File 'lib/activerecord-copy/temp_buffer.rb', line 11

def write(st)
  @st << st.dup.force_encoding(ASCII_8BIT_ENCODING)
end