Class: TkInspect::ClassBrowser::ModuleMethodDataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/tk_inspect/class_browser/module_method_data_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#selected_classObject

Returns the value of attribute selected_class.



4
5
6
# File 'lib/tk_inspect/class_browser/module_method_data_source.rb', line 4

def selected_class
  @selected_class
end

Instance Method Details

#items_for_path(path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/tk_inspect/class_browser/module_method_data_source.rb', line 6

def items_for_path(path)
  path = [] if path.blank?
  case path.size
  when 0
    return modules_of(selected_class)
  when 1
    return methods_of(path.first)
  else
    return []
  end
end

#title_for_path(path, items) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tk_inspect/class_browser/module_method_data_source.rb', line 18

def title_for_path(path, items)
  path = [] if path.blank?
  case path.size
  when 0
    return "#{selected_class} -> #{items.size} #{'module'.pluralize(items.size)}"
  when 1
    if (module_name = path.first).present?
      return "#{module_name} -> #{items.size} #{'method'.pluralize(items.size)}"
    else
      "#{items.size} #{'method'.pluralize(items.size)} in total"
    end
  else
    return ''
  end
end