Module: Lookbook::Where
- Defined in:
- lib/lookbook/support/utils/where.rb
Class Attribute Summary collapse
Class Method Summary collapse
- .is_class(klass) ⇒ Object
- .is_instance_method(klass, method_name) ⇒ Object
- .is_method(klass, method_name) ⇒ Object
- .is_proc(proc) ⇒ Object
Class Attribute Details
.editor ⇒ Object
4 5 6 |
# File 'lib/lookbook/support/utils/where.rb', line 4 def editor @editor end |
Class Method Details
.is_class(klass) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lookbook/support/utils/where.rb', line 18 def is_class(klass) methods = defined_methods(klass) file_groups = methods.group_by { |sl| sl[0] } file_counts = file_groups.map do |file, sls| lines = sls.map { |sl| sl[1] } count = lines.size line = lines.min {file: file, count: count, line: line} end file_counts.sort_by! { |fc| fc[:count] } file_counts.map { |fc| [fc[:file], fc[:line]] } end |
.is_instance_method(klass, method_name) ⇒ Object
14 15 16 |
# File 'lib/lookbook/support/utils/where.rb', line 14 def is_instance_method(klass, method_name) source_location(klass.instance_method(method_name)) end |
.is_method(klass, method_name) ⇒ Object
10 11 12 |
# File 'lib/lookbook/support/utils/where.rb', line 10 def is_method(klass, method_name) source_location(klass.method(method_name)) end |
.is_proc(proc) ⇒ Object
6 7 8 |
# File 'lib/lookbook/support/utils/where.rb', line 6 def is_proc(proc) source_location(proc) end |