Class: ActionView::MissingTemplate::Results
- Inherits:
-
Object
- Object
- ActionView::MissingTemplate::Results
- Defined in:
- lib/action_view/template/error.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #add(path, score) ⇒ Object
-
#initialize(size) ⇒ Results
constructor
A new instance of Results.
- #should_record?(score) ⇒ Boolean
- #to_a ⇒ Object
Constructor Details
#initialize(size) ⇒ Results
Returns a new instance of Results.
63 64 65 66 |
# File 'lib/action_view/template/error.rb', line 63 def initialize(size) @size = size @results = [] end |
Instance Method Details
#add(path, score) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/action_view/template/error.rb', line 80 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
72 73 74 75 76 77 78 |
# File 'lib/action_view/template/error.rb', line 72 def should_record?(score) if @results.size < @size true else score < @results.last.score end end |
#to_a ⇒ Object
68 69 70 |
# File 'lib/action_view/template/error.rb', line 68 def to_a @results.map(&:path) end |