Sha256: 7f11a1e3c683beda6da88cd29b137cc16d4008479bfc574ee1cca8fec2169265

Contents?: true

Size: 627 Bytes

Versions: 2

Compression:

Stored size: 627 Bytes

Contents

class YamlQuery::Output
  def flatten_results
    # TODO
  end

  def self.display_results(file, results, options)
    puts file
    if options[:onlyfile?]
    elsif options[:depth]
      gather_keys(results, options[:depth])
    elsif options[:yaml?]
      puts Psych.dump(results)
      puts
    elsif options[:oneline?]
      p results
      puts
    else
      pp results
      puts
    end
  end

  def self.gather_keys(results, depth, index = 1)
    if index == depth.to_i
      puts results.keys
    else
      results.each do |k, v|
        gather_keys(v, depth, index + 1) if v.is_a?(Hash)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yamlquery-0.0.2 lib/yamlquery/output.rb
yamlquery-0.0.1 lib/yamlquery/output.rb