Class: SIGADParse

Inherits:
Object
  • Object
show all
Defined in:
lib/sigadparse.rb

Instance Method Summary collapse

Constructor Details

#initialize(input, field) ⇒ SIGADParse

Returns a new instance of SIGADParse.



4
5
6
7
# File 'lib/sigadparse.rb', line 4

def initialize(input, field)
  @input = JSON.parse(input)
  @field = field
end

Instance Method Details

#matchObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/sigadparse.rb', line 9

def match
  matcharr = Array.new
  @input.each do |i|
    if i[@field]
      i[:sigads] = i[@field].scan(/(?:US|CA|UK|NZ|AU|DS|us|ca|uk|nz|au|ds)[a-zA-Z]?-\d(?:\w|-|\*){1,6}/)
      matcharr.push(i)
    end
  end
  JSON.pretty_generate(matcharr)
end