Class: YamlQuery::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/yamlquery/output.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.display_results(file, results, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/yamlquery/output.rb', line 6

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

.gather_keys(results, depth, index = 1) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/yamlquery/output.rb', line 23

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

Instance Method Details

#flatten_resultsObject



2
3
4
# File 'lib/yamlquery/output.rb', line 2

def flatten_results
  # TODO
end