class ExplainResult

Public Class Methods

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

Public Instance Methods

ast() click to toggle source
# File lib/rbhive/explain_result.rb, line 6
def ast
  by_section[:abstract_syntax_tree].first
end
raw() click to toggle source
# File lib/rbhive/explain_result.rb, line 22
def raw
  @rows
end
stage_count() click to toggle source
# File lib/rbhive/explain_result.rb, line 10
def stage_count
  stage_dependencies.length
end
stage_dependencies() click to toggle source
# File lib/rbhive/explain_result.rb, line 14
def stage_dependencies
  by_section[:stage_dependencies] || []
end
to_s() click to toggle source
# File lib/rbhive/explain_result.rb, line 26
def to_s
  to_tsv
end
to_tsv() click to toggle source
# File lib/rbhive/explain_result.rb, line 18
def to_tsv
  @rows.join("\n")
end

Private Instance Methods

by_section() click to toggle source
# File lib/rbhive/explain_result.rb, line 32
def by_section
  current_section = nil
  @rows.inject({}) do |sections, row|
    if row.match(/^[A-Z]/)
      current_section = row.chomp(':').downcase.gsub(' ', '_').to_sym
      sections[current_section] = []
    elsif row.length == 0
      next sections
    else
      sections[current_section] << row.strip
    end
    sections
  end
end