Class: Contracto::Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(strings_with_json) ⇒ Parser



6
7
8
# File 'lib/contracto/parser.rb', line 6

def initialize(strings_with_json)
  @json_collection = strings_with_json.map { |string| JSON.parse(string) }
end

Instance Method Details

#contractsObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/contracto/parser.rb', line 10

def contracts
  @json_collection.map do |json|
    json = [json] unless json.is_a?(Array)
    json.map do |json|
      Contracto::Contract.new(json)
    end
  end.flatten.tap do |contracts|
    Contracto::Stats.all_contracts = contracts
  end
end