Sha256: a7a8dc2418265f68ecc3e247fa92f77adc24a465e11365638280f40216d1a622
Contents?: true
Size: 998 Bytes
Versions: 20
Compression:
Stored size: 998 Bytes
Contents
class Parser attr_accessor :output def initialize(field_name, qualifier_value, hash) @field_name = field_name @qualifier_value = qualifier_value @hash = hash end def parse if @qualifier_value.nil? recurse @hash else qualified_recurse @hash end end def recurse(object) if object.is_a? Hash if object.has_key? @field_name @output = object[@field_name] else object.each_pair do |_key, value| recurse value end end elsif object.is_a? Array object.each do |element| recurse element end end end def qualified_recurse(object) if object.is_a? Hash if object.has_value? @qualifier_value @output = object[@field_name] else object.each_pair do |_key, value| qualified_recurse value end end elsif object.is_a? Array object.each do |element| qualified_recurse element end end end end
Version data entries
20 entries across 20 versions & 1 rubygems