Class: Solis::OverlayFS::OverlayIO

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/solis/overlay_fs.rb

Overview

IO wrapper that handles copy-up on write

Instance Method Summary collapse

Constructor Details

#initialize(io, overlay_fs: nil, relative_path: nil, mode: 'r') ⇒ OverlayIO

Returns a new instance of OverlayIO.



28
29
30
31
32
33
34
# File 'lib/solis/overlay_fs.rb', line 28

def initialize(io, overlay_fs: nil, relative_path: nil, mode: 'r')
  @io = io
  @overlay_fs = overlay_fs
  @relative_path = relative_path
  @mode = mode
  @copied_up = false
end

Instance Method Details

#<<(data) ⇒ Object



56
57
58
59
60
# File 'lib/solis/overlay_fs.rb', line 56

def <<(data)
  ensure_copy_up if @overlay_fs && !@copied_up
  @io << data
  self
end

#closeObject



66
67
68
# File 'lib/solis/overlay_fs.rb', line 66

def close
  @io.close
end

#close_writeObject



74
75
76
# File 'lib/solis/overlay_fs.rb', line 74

def close_write
  @io.close_write
end

#closed?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/solis/overlay_fs.rb', line 70

def closed?
  @io.closed?
end

#flushObject



62
63
64
# File 'lib/solis/overlay_fs.rb', line 62

def flush
  @io.flush
end

#pathObject



78
79
80
# File 'lib/solis/overlay_fs.rb', line 78

def path
  @io.respond_to?(:path) ? @io.path : nil
end


46
47
48
49
# File 'lib/solis/overlay_fs.rb', line 46

def print(*args)
  ensure_copy_up if @overlay_fs && !@copied_up
  @io.print(*args)
end

#printf(*args) ⇒ Object



51
52
53
54
# File 'lib/solis/overlay_fs.rb', line 51

def printf(*args)
  ensure_copy_up if @overlay_fs && !@copied_up
  @io.printf(*args)
end

#puts(*args) ⇒ Object



41
42
43
44
# File 'lib/solis/overlay_fs.rb', line 41

def puts(*args)
  ensure_copy_up if @overlay_fs && !@copied_up
  @io.puts(*args)
end

#to_ioObject



82
83
84
# File 'lib/solis/overlay_fs.rb', line 82

def to_io
  @io
end

#write(data) ⇒ Object



36
37
38
39
# File 'lib/solis/overlay_fs.rb', line 36

def write(data)
  ensure_copy_up if @overlay_fs && !@copied_up
  @io.write(data)
end