Class: SubSpawn::Internal::FdSource::File
- Inherits:
-
Open
- Object
- SubSpawn::Internal::FdSource
- Open
- SubSpawn::Internal::FdSource::File
- Defined in:
- lib/subspawn/fd_types.rb
Instance Attribute Summary
Attributes inherited from SubSpawn::Internal::FdSource
Instance Method Summary collapse
- #apply(base) ⇒ Object
-
#initialize(dests, file, mode = ::File::RDONLY, perm = 0o666) ⇒ File
constructor
A new instance of File.
- #to_dbg ⇒ Object
Methods inherited from SubSpawn::Internal::FdSource
#before?, #depends?, #destroys?, #heads, #max, #raw_apply, #tails
Constructor Details
#initialize(dests, file, mode = ::File::RDONLY, perm = 0o666) ⇒ File
Returns a new instance of File.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/subspawn/fd_types.rb', line 91 def initialize(dests, file, mode = ::File::RDONLY, perm = 0o666) super(dests) @value = file @mode = mode || ::File::RDONLY if @mode.respond_to? :to_str @mode = case @mode.to_str when "w" then IO::WRONLY | IO::CREAT | IO::TRUNC when "r" then IO::RDONLY when "rb" then IO::RDONLY | IO::BINARY when "wb" then IO::WRONLY | IO::BINARY | IO::CREAT | IO::TRUNC when "r+", "w+" then IO::RDWR | IO::CREAT # TODO: all! else raise ArgumentError "Unknown File mode" end end @perm = perm || 0o666 end |
Instance Method Details
#apply(base) ⇒ Object
112 113 114 115 116 117 |
# File 'lib/subspawn/fd_types.rb', line 112 def apply base first, *rest = @dests base.fd_open(first, @value, @mode, @perm) rest.each {|dest| base.fd(dest, first) } nil end |
#to_dbg ⇒ Object
109 110 111 |
# File 'lib/subspawn/fd_types.rb', line 109 def to_dbg [@dests, :file, @value, @mode, @perm] end |