noaaish 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d21d11e81cd686f346ad8dc630a6f9df8ca48ad7
4
- data.tar.gz: 8b2957ff63e2e295abe7caccf29a4bba682fccea
3
+ metadata.gz: 6807e1bf053998c145c7f274f0f8fe553b9ddeaa
4
+ data.tar.gz: 57141cecd357c26ffad7460136b93e51811bda83
5
5
  SHA512:
6
- metadata.gz: f537ebede1452a4acb48c3b3e050fe237cddcc9a0875e59cdb282fb1ba159c0bb9d80f5f6f98ce494d66879c5946db647497a470a3e0d7612f872574ae8113a2
7
- data.tar.gz: 190cdace5086eba162c1426b802fcf74216d9b46cce186c5018b2c75ae8feec34772717bce8ba75c1a449dba9b2cea9405561125c753078936a8a29af40ed9ea
6
+ metadata.gz: e7a504ea0cfd16e33bc21e86709481ec59f2c75d9d7f3cb557714591d08be9de0d94c5e15d6a9f14bc7d6ec50d344149133eb283645975df03317cd2e6cef04a
7
+ data.tar.gz: c2bbad6afdbab31eae2bcdf25ff0f371556a68143e2b0b178cee4e16ce50c9452079431fbb5e9912da73d9a956543413d5b6d52e051dc0df10d625e1f295ed8a
@@ -3,22 +3,29 @@ require 'tempfile'
3
3
 
4
4
  module Noaaish
5
5
  class Extractor
6
- def initialize(input, output=destination)
6
+ def initialize(input, output=destination, format=:hash)
7
7
  @input = input
8
8
  @destination = output
9
+ @format = format
9
10
  end
10
11
 
11
- attr_reader :input
12
+ attr_reader :input, :format
12
13
 
13
14
  def call
14
15
  # For each line, create a json record.
15
- destination.write(input.each_line.map { |line|
16
- NOAA_FIELDS.inject({}) do |hash, (field, range)|
17
- hash.merge(field => line[range])
18
- end
19
- }
20
- .to_json)
21
- destination
16
+ hash = input.each_line.map { |line|
17
+ NOAA_FIELDS.inject({}) do |hash, (field, range)|
18
+ hash.merge(field => line[range])
19
+ end
20
+ }
21
+
22
+ case format
23
+ when :json
24
+ destination << hash.to_json
25
+ destination
26
+ when :hash
27
+ hash
28
+ end
22
29
  end
23
30
 
24
31
  def destination
@@ -1,3 +1,3 @@
1
1
  module Noaaish
2
- VERSION = "1.0.1"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noaaish
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schneider