Method: Autocad::Drawing#copy

Defined in:
lib/autocad/drawing.rb

#copy(name: nil, dir: nil) ⇒ void

This method returns an undefined value.

Copy the drawing to a new file

Examples:

Create a backup copy

drawing.copy(name: "backup_#{Time.now.strftime('%Y%m%d')}.dwg")

Parameters:

  • name (String, Pathname, nil) (defaults to: nil)

    Name of the file

  • dir (String, Pathname, nil) (defaults to: nil)

    Target directory



203
204
205
206
207
208
209
210
211
212
213
# File 'lib/autocad/drawing.rb', line 203

def copy(name: nil, dir: nil) #: void

  if dir.nil?
    lname = name || copy_name
    dir_path = dirname
  else
    lname = name || self.name
    dir_path = Pathname.new(dir)
  end
  copy_path = dir_path + lname
  FileUtils.copy path.to_s, copy_path.to_s, verbose: true
end