Class: YamlQuery::Output
- Inherits:
-
Object
- Object
- YamlQuery::Output
- 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, ) puts file if [:onlyfile?] elsif [:depth] gather_keys(results, [:depth]) elsif [:yaml?] puts Psych.dump(results) puts elsif [: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_results ⇒ Object
2 3 4 |
# File 'lib/yamlquery/output.rb', line 2 def flatten_results # TODO end |