class Searchr::ExplainLine
Attributes
indent_level[R]
line[R]
Public Class Methods
new(line)
click to toggle source
# File lib/searchr/explanation_parser.rb, line 75 def initialize(line) num_spaces = (/^\s*/.match line).to_s.size @indent_level = num_spaces / 2 @line = line[num_spaces..line.size] end
node(str)
click to toggle source
# File lib/searchr/explanation_parser.rb, line 71 def self.node(str) self.new(str).node end
Public Instance Methods
line_type()
click to toggle source
# File lib/searchr/explanation_parser.rb, line 85 def line_type return ProductNode if @line.include? ') product of:' return SumNode if @line.include? ') sum of:' return MaxNode if @line.include? ') max of:' return WeightNode if @line.include? ') weight(' return CoordNode if @line.include? '= coord(' msg = "Unknown line type: #{@line}" msg.logit raise msg end
node(parent)
click to toggle source
# File lib/searchr/explanation_parser.rb, line 81 def node(parent) line_type.new parent, self end
score()
click to toggle source
# File lib/searchr/explanation_parser.rb, line 96 def score @score ||= line.to_f end