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
- #additional_processing_types ⇒ Object
- #identifier_with_additional_processing ⇒ Object
-
#initialize(const) ⇒ Collaborators
constructor
A new instance of Collaborators.
- #lexed ⇒ Object
- #rank ⇒ Object
- #tally ⇒ Object
Constructor Details
#initialize(const) ⇒ Collaborators
Returns a new instance of Collaborators.
7 8 9 |
# File 'lib/klee/collaborators.rb', line 7 def initialize(const) @const = const end |
Instance Attribute Details
#const ⇒ Object (readonly)
Returns the value of attribute const.
10 11 12 |
# File 'lib/klee/collaborators.rb', line 10 def const @const end |
Instance Method Details
#additional_processing_types ⇒ Object
16 |
# File 'lib/klee/collaborators.rb', line 16 def additional_processing_types = [:DOT, :BRACKET_LEFT] |
#identifier_with_additional_processing ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/klee/collaborators.rb', line 18 def identifier_with_additional_processing lexed.value.each_cons(2).filter_map do |(token, next_token)| if token.first.type == :IDENTIFIER && additional_processing_types.include?(next_token.first.type) token.first.value end end end |
#lexed ⇒ Object
12 13 14 |
# File 'lib/klee/collaborators.rb', line 12 def lexed Prism.lex_file(Object.const_source_location(const.name).first) end |
#rank ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/klee/collaborators.rb', line 31 def rank tally.group_by do |_, count| count end.sort.reverse.to_h.transform_values do |value| value.map(&:first) end.reject do |key, value| value.empty? || key < 3 end end |
#tally ⇒ Object
27 28 29 |
# File 'lib/klee/collaborators.rb', line 27 def tally identifier_with_additional_processing.tally end |