Module: Transcriber::Resource::Parser

Included in:
Transcriber::Resource, Embeddable, Property
Defined in:
lib/transcriber/resource/parser.rb

Instance Method Summary collapse

Instance Method Details

#parse(input, options = {}) ⇒ Object



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

def parse(input, options = {})
  entries = prepare_entries(input, options)

  if entries.any? {|e| !e.kind_of?(Hash)}
    fail "invalid input" if options[:fail]
    return []
  end

  entries.collect do |item|
    parse_item(item.with_indifferent_access, options)
  end
end

#parse!(input, options = {}) ⇒ Object



4
5
6
# File 'lib/transcriber/resource/parser.rb', line 4

def parse!(input, options = {})
  parse(input, options.merge(fail: true))
end