Class: Remote::Session::Send

Inherits:
Object
  • Object
show all
Defined in:
lib/remote/session/send.rb

Direct Known Subclasses

SendFile, SendString

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote_path) ⇒ Send

Returns a new instance of Send.



10
11
12
13
14
# File 'lib/remote/session/send.rb', line 10

def initialize( remote_path )
  @remote_path = remote_path
  @chunk_size  = 1024
  @file        = nil
end

Instance Attribute Details

#chunk_sizeObject

Returns the value of attribute chunk_size.



8
9
10
# File 'lib/remote/session/send.rb', line 8

def chunk_size
  @chunk_size
end

#remote_pathObject

Returns the value of attribute remote_path.



7
8
9
# File 'lib/remote/session/send.rb', line 7

def remote_path
  @remote_path
end

Instance Method Details

#closeObject



40
41
42
43
44
# File 'lib/remote/session/send.rb', line 40

def close
  return if ! open?
  @file.close
  @file = nil
end

#eof?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/remote/session/send.rb', line 22

def eof?
  return true if ! open?
  @file.eof?
end

#openObject



31
32
33
34
35
36
37
38
# File 'lib/remote/session/send.rb', line 31

def open
  if open?
    @file.rewind
    return
  end

  _open
end

#open?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/remote/session/send.rb', line 27

def open?
  ! @file.nil?
end

#readObject



16
17
18
19
20
# File 'lib/remote/session/send.rb', line 16

def read
  open if ! open?
  
  @file.read( @chunk_size )
end