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.
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
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_a ⇒ Object
67 68 69 |
# File 'lib/action_view/template/error.rb', line 67 def to_a @results.map(&:path) end |