enum Chem::IO::FileFormat
Defined in:
chem/io/formats.crEnum Members
-
Chgcar =
0
-
Cube =
1
-
DX =
2
-
Gen =
3
-
Locpot =
4
-
Mol2 =
5
-
PDB =
6
-
Poscar =
7
-
PyMOL =
8
-
Stride =
9
-
VMD =
10
-
XYZ =
11
Constructors
-
.from_ext(extname : String) : self
Returns the file format associated with extname, or raises
ArgumentError
otherwise. -
.from_filename(filename : Path | String) : self
Returns the file format associated with filename, or raises
ArgumentError
otherwise. -
.from_stem(stem : Path | String) : self
Returns the file format associated with stem, or raises
ArgumentError
otherwise.
Class Method Summary
-
.from_ext?(extname : String) : self | Nil
Returns the file format associated with extname, or
nil
otherwise. -
.from_filename?(filename : Path | String) : self | Nil
Returns the file format associated with filename, or
nil
otherwise. -
.from_stem?(stem : String) : self | Nil
Returns the file format associated with stem, or
nil
otherwise.
Instance Method Summary
- #chgcar? : Bool
- #cube? : Bool
- #dx? : Bool
- #extnames : Array(String)
- #gen? : Bool
- #locpot? : Bool
- #mol2? : Bool
- #pdb? : Bool
- #poscar? : Bool
- #py_mol?
- #pymol? : Bool
- #stride? : Bool
- #vmd? : Bool
- #xyz? : Bool
Constructor Detail
Returns the file format associated with extname, or raises ArgumentError
otherwise.
@[FileType(format: Image, ext: %w(tiff png jpg))]
...
FileFormat.from_ext("img.tiff") # => FileFormat::Image
FileFormat.from_ext("img.TIFF") # => FileFormat::Image
FileFormat.from_ext("img.png") # => FileFormat::Image
FileFormat.from_ext("img.txt") # => raises ArgumentError
NOTE it performs a case-insensitive search so .tiff and .TIFF return the same.
Returns the file format associated with filename, or raises ArgumentError
otherwise.
It first looks up the file format associated with the extension in filename
via .from_ext?
. If this yields no result, then it executes a case-insensitive
search with the stem in filename via .from_stem?
.
@[FileType(format: Image, ext: %w(tiff png jpg), names: %w(IMG*))]
...
FileFormat.from_filename("IMG_2314.tiff") # => FileFormat::Image
FileFormat.from_filename("IMG_2314.png") # => FileFormat::Image
FileFormat.from_filename("IMG_2314") # => FileFormat::Image
FileFormat.from_filename("img_2314") # => FileFormat::Image
FileFormat.from_filename("img2314") # => FileFormat::Image
FileFormat.from_filename("Imi") # => raises ArgumentError
Returns the file format associated with stem, or raises ArgumentError
otherwise.
The comparison is made using String#camelcase
and String#downcase
, so a file
format named ChgCar
will match "CHGCAR"
, "ChgCar"
, "chgcar"
, "CHG_CAR"
and "chg_car"
.
@[FileType(format: Image, names: %w(IMG*))]
...
FileFormat.from_stem("IMG_2314") # => FileFormat::Image
FileFormat.from_stem("img_2314") # => FileFormat::Image
FileFormat.from_stem("img2314") # => FileFormat::Image
FileFormat.from_stem("Imi") # => raises ArgumentError
Class Method Detail
Returns the file format associated with extname, or nil
otherwise.
@[FileType(format: Image, ext: %w(tiff png jpg))]
...
FileFormat.from_ext?("img.tiff") # => FileFormat::Image
FileFormat.from_ext?("img.TIFF") # => FileFormat::Image
FileFormat.from_ext?("img.png") # => FileFormat::Image
FileFormat.from_ext?("img.txt") # => nil
NOTE it performs a case-insensitive search so .tiff and .TIFF return the same.
Returns the file format associated with filename, or nil
otherwise.
It first looks up the file format associated with the extension in filename
via .from_ext?
. If this yields no result, then it executes a case-insensitive
search with the stem in filename via .from_stem?
.
@[FileType(format: Image, ext: %w(tiff png jpg), names: %w(IMG*))]
...
FileFormat.from_filename?("IMG_2314.tiff") # => FileFormat::Image
FileFormat.from_filename?("IMG_2314.png") # => FileFormat::Image
FileFormat.from_filename?("IMG_2314") # => FileFormat::Image
FileFormat.from_filename?("img_2314") # => FileFormat::Image
FileFormat.from_filename?("img2314") # => FileFormat::Image
FileFormat.from_filename?("Imi") # => nil
Returns the file format associated with stem, or nil
otherwise.
The comparison is made using String#camelcase
and String#downcase
, so a file
format named ChgCar
will match "CHGCAR"
, "ChgCar"
, "chgcar"
, "CHG_CAR"
and "chg_car"
.
@[FileType(format: Image, names: %w(IMG*))]
...
FileFormat.from_stem?("IMG_2314") # => FileFormat::Image
FileFormat.from_stem?("img_2314") # => FileFormat::Image
FileFormat.from_stem?("img2314") # => FileFormat::Image
FileFormat.from_stem?("Imi") # => nil