Method: BibTeX::Element.parse
- Defined in:
- lib/bibtex/elements.rb
.parse(input, options = {}) ⇒ Object
Returns an array of BibTeX elements.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bibtex/elements.rb', line 30 def self.parse(input, = {}) case input when Element [input] when Hash [Entry.new(input)] when Array input.inject([]) { |s, a| s.concat(parse(a, )) } when ::String Parser.new().parse(input).data.each do |e| e.parse_names unless !e.respond_to?(:parse_names) || [:parse_names] == false e.parse_month unless !e.respond_to?(:parse_month) || [:parse_months] == false end else raise ArgumentError, "failed to parse Element from #{input.inspect}" end end |