Class: Inch::Evaluation::File
- Inherits:
-
Object
- Object
- Inch::Evaluation::File
- Defined in:
- lib/inch/evaluation/file.rb
Overview
Evaluation::File is used in the Suggest API/CLI to determine the importance of files
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#objects ⇒ Object
Returns the value of attribute objects.
Class Method Summary collapse
Instance Method Summary collapse
- #fullname ⇒ Object
-
#grade ⇒ Object
grade, priority and score are not meant to be displayed in the CLI they are just for internal evaluation purposes.
-
#initialize(filename, objects) ⇒ File
constructor
A new instance of File.
- #priority ⇒ Object
- #score ⇒ Object
Constructor Details
#initialize(filename, objects) ⇒ File
Returns a new instance of File.
8 9 10 11 12 13 |
# File 'lib/inch/evaluation/file.rb', line 8 def initialize(filename, objects) self.filename = filename self.objects = objects.select do |o| o.filename == filename end end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
6 7 8 |
# File 'lib/inch/evaluation/file.rb', line 6 def filename @filename end |
#objects ⇒ Object
Returns the value of attribute objects.
6 7 8 |
# File 'lib/inch/evaluation/file.rb', line 6 def objects @objects end |
Class Method Details
.for(filename, objects) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/inch/evaluation/file.rb', line 53 def for(filename, objects) @cache ||= {} if (file = @cache[filename]) file else @cache[filename] = new(filename, objects) end end |
Instance Method Details
#fullname ⇒ Object
Note:
added to be compatible with code objects
16 17 18 |
# File 'lib/inch/evaluation/file.rb', line 16 def fullname filename end |
#grade ⇒ Object
grade, priority and score are not meant to be displayed in the CLI they are just for internal evaluation purposes
25 26 27 |
# File 'lib/inch/evaluation/file.rb', line 25 def grade median(grades.sort_by(&:to_sym)) end |
#priority ⇒ Object
29 30 31 |
# File 'lib/inch/evaluation/file.rb', line 29 def priority median(priorities.sort) end |
#score ⇒ Object
33 34 35 |
# File 'lib/inch/evaluation/file.rb', line 33 def score objects.select(&:undocumented?).size end |