class ExplainResult

Public Class Methods

new(rows) click to toggle source
  # File lib/rbhive/explain_result.rb
2 def initialize(rows)
3   @rows = rows
4 end

Public Instance Methods

ast() click to toggle source
  # File lib/rbhive/explain_result.rb
6 def ast
7   by_section[:abstract_syntax_tree].first
8 end
raw() click to toggle source
   # File lib/rbhive/explain_result.rb
22 def raw
23   @rows
24 end
stage_count() click to toggle source
   # File lib/rbhive/explain_result.rb
10 def stage_count
11   stage_dependencies.length
12 end
stage_dependencies() click to toggle source
   # File lib/rbhive/explain_result.rb
14 def stage_dependencies
15   by_section[:stage_dependencies] || []
16 end
to_s() click to toggle source
   # File lib/rbhive/explain_result.rb
26 def to_s
27   to_tsv
28 end
to_tsv() click to toggle source
   # File lib/rbhive/explain_result.rb
18 def to_tsv
19   @rows.join("\n")
20 end

Private Instance Methods

by_section() click to toggle source
   # File lib/rbhive/explain_result.rb
32 def by_section
33   current_section = nil
34   @rows.inject({}) do |sections, row|
35     if row.match(/^[A-Z]/)
36       current_section = row.chomp(':').downcase.gsub(' ', '_').to_sym
37       sections[current_section] = []
38     elsif row.length == 0
39       next sections
40     else
41       sections[current_section] << row.strip
42     end
43     sections
44   end
45 end