Class: ChefAPI::Multipart::FilePart

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-api/multipart.rb

Overview

A File part

Instance Method Summary collapse

Constructor Details

#initialize(name, file) ⇒ FilePart

Returns a new instance of FilePart.



113
114
115
116
117
# File 'lib/chef-api/multipart.rb', line 113

def initialize(name, file)
  @file = file
  @head = build(name, file)
  @foot = "\r\n"
end

Instance Method Details

#ioObject



119
120
121
122
123
124
125
# File 'lib/chef-api/multipart.rb', line 119

def io
  @io ||= MultiIO.new(
    StringIO.new(@head),
    @file,
    StringIO.new(@foot)
  )
end

#sizeObject



127
128
129
# File 'lib/chef-api/multipart.rb', line 127

def size
  @head.bytesize + @file.size + @foot.bytesize
end