Class: Gribr::Degrib::File
- Inherits:
-
File
- Object
- File
- Gribr::Degrib::File
- Defined in:
- lib/gribr/degrib/file.rb
Instance Method Summary collapse
-
#index ⇒ Object
Return the degrib index file.
-
#index! ⇒ Object
Build the degrib index file.
-
#indexed? ⇒ Boolean
Return true if the degrib index file exists.
-
#indexname ⇒ Object
Returns the pathname of the degrib index file.
-
#initialize(*params) ⇒ File
constructor
A new instance of File.
-
#inventory(options = {}) ⇒ Object
Returns the inventory of the file.
-
#messages ⇒ Object
Returns the messages in the grib file.
-
#probe(latitude, longitude, options = { }, &block) ⇒ Object
Probe the grib file at the given location and return/yield the records.
Constructor Details
#initialize(*params) ⇒ File
Returns a new instance of File.
9 10 11 |
# File 'lib/gribr/degrib/file.rb', line 9 def initialize(*params) super; validate! end |
Instance Method Details
#index ⇒ Object
Return the degrib index file.
14 15 16 |
# File 'lib/gribr/degrib/file.rb', line 14 def index @index ||= (indexed? ? Index.new(indexname) : Index.create(self)) end |
#index! ⇒ Object
Build the degrib index file.
19 20 21 |
# File 'lib/gribr/degrib/file.rb', line 19 def index! @index = Index.create!(self) end |
#indexed? ⇒ Boolean
Return true if the degrib index file exists.
24 25 26 |
# File 'lib/gribr/degrib/file.rb', line 24 def indexed? File.exists?(indexname) end |
#indexname ⇒ Object
Returns the pathname of the degrib index file.
29 30 31 |
# File 'lib/gribr/degrib/file.rb', line 29 def indexname path.gsub(Regexp.new("#{File.extname(path)}$"), ".#{Index::EXTNAME}") end |
#inventory(options = {}) ⇒ Object
Returns the inventory of the file.
34 35 36 |
# File 'lib/gribr/degrib/file.rb', line 34 def inventory( = {}) @inventory ||= Inventory.file(self) end |
#messages ⇒ Object
Returns the messages in the grib file.
39 40 41 |
# File 'lib/gribr/degrib/file.rb', line 39 def || inventory.records.map { |record| Message.new(self, record) } end |
#probe(latitude, longitude, options = { }, &block) ⇒ Object
Probe the grib file at the given location and return/yield the records.
45 46 47 |
# File 'lib/gribr/degrib/file.rb', line 45 def probe(latitude, longitude, = { }, &block) probe_one(latitude, longitude, , &block) end |