Class: Aws::S3::FilePart Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-resources/services/s3/file_part.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A utility class that provides an IO-like interface to a portion of a file on disk.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FilePart

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of FilePart.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :source (required, String, Pathname, File, Tempfile)
  • :offset (required, Integer)

    The file part will read starting at this byte offset.

  • :size (required, Integer)

    The maximum number of bytes to read from the ‘:offset`.



14
15
16
17
18
19
20
# File 'lib/aws-sdk-resources/services/s3/file_part.rb', line 14

def initialize(options = {})
  @source = options[:source]
  @first_byte = options[:offset]
  @last_byte = @first_byte + options[:size]
  @size = options[:size]
  @file = nil
end

Instance Attribute Details

#first_byteInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


26
27
28
# File 'lib/aws-sdk-resources/services/s3/file_part.rb', line 26

def first_byte
  @first_byte
end

#last_byteInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


29
30
31
# File 'lib/aws-sdk-resources/services/s3/file_part.rb', line 29

def last_byte
  @last_byte
end

#sizeInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


32
33
34
# File 'lib/aws-sdk-resources/services/s3/file_part.rb', line 32

def size
  @size
end

#sourceString, ... (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String, Pathname, File, Tempfile)


23
24
25
# File 'lib/aws-sdk-resources/services/s3/file_part.rb', line 23

def source
  @source
end

Instance Method Details

#closeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
# File 'lib/aws-sdk-resources/services/s3/file_part.rb', line 47

def close
  @file.close if @file
end

#read(bytes = nil, output_buffer = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
37
# File 'lib/aws-sdk-resources/services/s3/file_part.rb', line 34

def read(bytes = nil, output_buffer = nil)
  open_file unless @file
  read_from_file(bytes, output_buffer)
end

#rewindObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
42
43
44
45
# File 'lib/aws-sdk-resources/services/s3/file_part.rb', line 39

def rewind
  if @file
    @file.seek(@first_byte)
    @position = @first_byte
  end
  0
end