Class: Inch::Evaluation::File

Inherits:
Object
  • Object
show all
Defined in:
lib/inch/evaluation/file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, objects) ⇒ File

Returns a new instance of File.



6
7
8
9
10
11
# File 'lib/inch/evaluation/file.rb', line 6

def initialize(filename, objects)
  self.filename = filename
  self.objects = objects.select do |o|
    o.filename == filename
  end
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



4
5
6
# File 'lib/inch/evaluation/file.rb', line 4

def filename
  @filename
end

#objectsObject

Returns the value of attribute objects.



4
5
6
# File 'lib/inch/evaluation/file.rb', line 4

def objects
  @objects
end

Class Method Details

.for(filename, objects) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/inch/evaluation/file.rb', line 51

def for(filename, objects)
  @cache ||= {}
  if file = @cache[filename]
    file
  else
    @cache[filename] = new(filename, objects)
  end
end

Instance Method Details

#fullnameObject

Note:

added to be compatible with code objects



14
15
16
# File 'lib/inch/evaluation/file.rb', line 14

def fullname
  filename
end

#gradeObject

grade, priority, and score are not meant to be displayed in the CLI they are just for internal evaluation purposes



23
24
25
# File 'lib/inch/evaluation/file.rb', line 23

def grade
  median(grades.sort_by(&:to_sym))
end

#priorityObject



27
28
29
# File 'lib/inch/evaluation/file.rb', line 27

def priority
  median(priorities.sort)
end

#scoreObject



31
32
33
# File 'lib/inch/evaluation/file.rb', line 31

def score
  objects.select(&:undocumented?).size
end