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.



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

Returns:

  • (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_aObject



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

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