module ImageMagick::Identify::Parser
Constants
- INDENT_PER_LEVEL
Public Class Methods
parse(input, spaces = INDENT_PER_LEVEL)
click to toggle source
# File lib/imagemagick/identify/parser.rb, line 9 def self.parse(input, spaces = INDENT_PER_LEVEL) matcher = /\n\s{#{spaces}}\b/ #new line with n spaces until the next word {}.tap{ |result| input.split(matcher).each do |string| if string.include?(":\n") key, value = string.split(":\n", 2).map(&:strip) result[key] = parse(value, spaces + INDENT_PER_LEVEL) else key, value = string.split(": ", 2).map(&:strip) result[key] = value end end } end