Class: ActionView::MissingTemplate::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view/template/error.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ Results

Returns a new instance of Results.



62
63
64
65
# File 'lib/action_view/template/error.rb', line 62

def initialize(size)
  @size = size
  @results = []
end

Instance Method Details

#add(path, score) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/action_view/template/error.rb', line 79

def add(path, score)
  if should_record?(score)
    @results << Result.new(path, score)
    @results.sort_by!(&:score)
    @results.pop if @results.size > @size
  end
end

#should_record?(score) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
# File 'lib/action_view/template/error.rb', line 71

def should_record?(score)
  if @results.size < @size
    true
  else
    score < @results.last.score
  end
end

#to_aObject



67
68
69
# File 'lib/action_view/template/error.rb', line 67

def to_a
  @results.map(&:path)
end