Class: Gribr::Degrib::Index
- Inherits:
-
File
- Object
- File
- Gribr::Degrib::Index
- Defined in:
- lib/gribr/degrib/index.rb
Constant Summary collapse
- EXTNAME =
"idx".freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#cube ⇒ Object
Returns the cube of the degrib index.
-
#cubename ⇒ Object
Returns the pathname of the degrib cube file.
- #delete ⇒ Object
Class Method Details
.command(file) ⇒ Object
27 28 29 30 |
# File 'lib/gribr/degrib/index.rb', line 27 def command(file) file = File.new(file.respond_to?(:path) ? file.path : file) unless file.kind_of?(File) "#{Degrib.executeable.name} #{file.path} -Data -Index #{file.indexname}" end |
.create(file) ⇒ Object
32 33 34 35 36 |
# File 'lib/gribr/degrib/index.rb', line 32 def create(file) gribfile = File.new(file.respond_to?(:path) ? file.path : file) system(command(gribfile)) new(gribfile.indexname) if $? == 0 end |
.create!(file) ⇒ Object
38 39 40 |
# File 'lib/gribr/degrib/index.rb', line 38 def create!(file) create(file) || raise("Can't create degrib index for #{file}.") end |
.extname ⇒ Object
42 43 44 |
# File 'lib/gribr/degrib/index.rb', line 42 def extname EXTNAME end |
Instance Method Details
#cube ⇒ Object
Returns the cube of the degrib index.
16 17 18 |
# File 'lib/gribr/degrib/index.rb', line 16 def cube @cube ||= Cube.new(cubename) end |
#cubename ⇒ Object
Returns the pathname of the degrib cube file.
21 22 23 |
# File 'lib/gribr/degrib/index.rb', line 21 def cubename path.gsub(Regexp.new("#{File.extname(path)}$"), ".#{Cube.extname}") end |
#delete ⇒ Object
10 11 12 13 |
# File 'lib/gribr/degrib/index.rb', line 10 def delete super cube.delete if cube.exist? end |