Module: Bri
- Defined in:
- lib/bri.rb,
lib/bri/mall.rb,
lib/bri/matcher.rb,
lib/bri/renderer.rb,
lib/bri/templates.rb,
lib/bri/match/base.rb,
lib/bri/match/class.rb,
lib/bri/search/base.rb,
lib/bri/match/method.rb,
lib/bri/search/class.rb,
lib/bri/search/method.rb,
lib/bri/search/class_method.rb,
lib/bri/search/instance_method.rb
Defined Under Namespace
Modules: Match, Renderer, Search, Templates
Classes: Mall, Matcher
Constant Summary
collapse
- DEFAULT_WIDTH =
72
Class Method Summary
collapse
Class Method Details
.list_classes ⇒ Object
49
50
51
|
# File 'lib/bri.rb', line 49
def self.list_classes
Bri::Mall.instance.classes.join("\n" )
end
|
.list_methods ⇒ Object
53
54
55
56
|
# File 'lib/bri.rb', line 53
def self.list_methods
( Bri::Mall.instance.instance_methods +
Bri::Mall.instance.class_methods ).sort.join( "\n" )
end
|
.list_names ⇒ Object
58
59
60
61
62
|
# File 'lib/bri.rb', line 58
def self.list_names
( Bri::Mall.instance.classes +
Bri::Mall.instance.instance_methods +
Bri::Mall.instance.class_methods ).sort.join( "\n" )
end
|
.ri(query, show_all: false) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/bri.rb', line 14
def self.ri( query, show_all: false )
results = Bri::Matcher.new( query ).find
if results.size == 0
"No matching results found"
elsif results.size == 1
results.first.to_s
elsif results.all? { |r| r.is_a?(Bri::Match::Class) }
if show_all
results.map(&:to_s)
else
gem_docs, core_docs = results.partition { |r| r.origin =~ %r{gem\b} }
docs_to_output = core_docs.empty? ? gem_docs : core_docs
docs_to_output.map(&:to_s)
end
else
qualified_methods = results.map(&:full_name).sort
ERB.new( Bri::Templates::MULTIPLE_CHOICES, nil, '<>' ).result( binding )
end
end
|
.width ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/bri.rb', line 36
def self.width
return @width if instance_variable_defined?( :@width )
base_width = ENV['COLUMNS'].to_i
base_width = 80 if base_width == 0
@width ||= [ base_width - 8, 1 ].max
end
|
.width=(width) ⇒ Object
45
46
47
|
# File 'lib/bri.rb', line 45
def self.width=( width )
@width = [ width, 1 ].max
end
|