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.
74 75 76 77 |
# File 'lib/action_view/template/error.rb', line 74 def initialize(size) @size = size @results = [] end |
Instance Method Details
#add(path, score) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/action_view/template/error.rb', line 91 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
83 84 85 86 87 88 89 |
# File 'lib/action_view/template/error.rb', line 83 def should_record?(score) if @results.size < @size true else score < @results.last.score end end |
#to_a ⇒ Object
79 80 81 |
# File 'lib/action_view/template/error.rb', line 79 def to_a @results.map(&:path) end |