module Microstation::FileTests

Public Instance Methods

check_is_dgn(f) click to toggle source
# File lib/microstation/file_tests.rb, line 29
def check_is_dgn(f)
  raise ArgumentError, 'File must be a dgn file' unless microstation_drawing?(f)
end
check_is_drawing(f) click to toggle source
# File lib/microstation/file_tests.rb, line 26
def check_is_drawing(f)
  raise ArgumentError, 'File must be a dgn or dwg file' unless drawing?(f)
end
drawing?(f) click to toggle source
# File lib/microstation/file_tests.rb, line 12
def drawing?(f)
  f = f.to_path if f.respond_to? :to_path
  f = f.to_str
  File.file?(f) && drawing_type?(f)
end
drawing_type?(f) click to toggle source
# File lib/microstation/file_tests.rb, line 19
def drawing_type?(f)
  f = f.to_path if f.respond_to? :to_path
  f = f.to_str
  ext = File.extname(f)
  ext == '.dwg' || ext == '.dgn'
end
microstation_drawing?(f) click to toggle source
# File lib/microstation/file_tests.rb, line 6
def microstation_drawing?(f)
  f = f.to_path if f.respond_to? :to_path
  f = f.to_str
  File.file?(f) && File.extname(f) == '.dgn'
end