Class: Klee::Collaborators
- Inherits:
-
Object
- Object
- Klee::Collaborators
- Defined in:
- lib/klee/collaborators.rb
Instance Attribute Summary collapse
-
#const ⇒ Object
readonly
Returns the value of attribute const.
Instance Method Summary collapse
-
#initialize(const) ⇒ Collaborators
constructor
A new instance of Collaborators.
- #rank ⇒ Object
- #tally ⇒ Object
Constructor Details
#initialize(const) ⇒ Collaborators
Returns a new instance of Collaborators.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/klee/collaborators.rb', line 5 def initialize(const) unless const.is_a?(Module) raise ArgumentError, "expected a class or module, got #{const.inspect}" end path = Object.const_source_location(const.name)&.first unless path && File.file?(path) raise Error, "cannot locate source for #{const}" end @const = const @analyzer = FileAnalyzer.new(path) end |
Instance Attribute Details
#const ⇒ Object (readonly)
Returns the value of attribute const.
18 19 20 |
# File 'lib/klee/collaborators.rb', line 18 def const @const end |
Instance Method Details
#rank ⇒ Object
24 25 26 27 28 29 |
# File 'lib/klee/collaborators.rb', line 24 def rank tally.group_by { |_, count| count } .sort.reverse.to_h .transform_values { |value| value.map(&:first) } .reject { |key, _value| key < 3 } end |
#tally ⇒ Object
20 21 22 |
# File 'lib/klee/collaborators.rb', line 20 def tally @analyzer.collaborators.tally end |