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, Search, Templates
Classes: Mall, Matcher, Renderer
Constant Summary
collapse
- DEFAULT_WIDTH =
72
Class Method Summary
collapse
Class Method Details
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/bri.rb', line 16
def self.format_elements( array )
rows = []
row = []
row_length = 0
array.each do |element|
element_length_with_separator = element.length + 2
if row_length + element_length_with_separator >= Bri.width
rows << row
row = []
row_length = 0
end
row << element
row_length += element_length_with_separator
end
rows << row
rows
end
|
.list_classes ⇒ Object
63
64
65
|
# File 'lib/bri.rb', line 63
def self.list_classes
Bri::Mall.instance.classes.join("\n" )
end
|
.list_methods ⇒ Object
67
68
69
70
|
# File 'lib/bri.rb', line 67
def self.list_methods
( Bri::Mall.instance.instance_methods +
Bri::Mall.instance.class_methods ).sort.join( "\n" )
end
|
.list_names ⇒ Object
72
73
74
75
76
|
# File 'lib/bri.rb', line 72
def self.list_names
( Bri::Mall.instance.classes +
Bri::Mall.instance.instance_methods +
Bri::Mall.instance.class_methods ).sort.join( "\n" )
end
|
.ri(query) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/bri.rb', line 38
def self.ri( query )
results = Bri::Matcher.new( query ).find
if results.size == 0
"No matching results found"
elsif results.size == 1
results.first.to_s
else
qualified_methods = results.collect{ |result| result.full_name }.sort
ERB.new( Bri::Templates::MULTIPLE_CHOICES, nil, '<>' ).result( binding )
end
end
|
.width ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/bri.rb', line 51
def self.width
return @@width if 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
59
60
61
|
# File 'lib/bri.rb', line 59
def self.width=( width )
@@width = [ width, 1 ].max
end
|