Class: DefaultDisplay
- Inherits:
-
Object
- Object
- DefaultDisplay
- Includes:
- RiDisplay
- Defined in:
- lib/rdoc/ri/ri_display.rb
Overview
####################################################################
A paging display module. Uses the ri_formatter class to do the actual presentation
Instance Method Summary collapse
-
#display_class_info(klass, ri_reader) ⇒ Object
####################################################################.
-
#display_class_list(namespaces) ⇒ Object
####################################################################.
-
#display_method_info(method) ⇒ Object
####################################################################.
-
#display_method_list(methods) ⇒ Object
Display a list of method names.
-
#display_usage ⇒ Object
####################################################################.
-
#initialize(options) ⇒ DefaultDisplay
constructor
A new instance of DefaultDisplay.
-
#list_known_classes(classes) ⇒ Object
####################################################################.
-
#list_known_names(names) ⇒ Object
####################################################################.
Methods included from RiDisplay
Constructor Details
#initialize(options) ⇒ DefaultDisplay
Returns a new instance of DefaultDisplay.
41 42 43 44 |
# File 'lib/rdoc/ri/ri_display.rb', line 41 def initialize() @options = @formatter = @options.formatter.new(@options, " ") end |
Instance Method Details
#display_class_info(klass, ri_reader) ⇒ Object
####################################################################
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/rdoc/ri/ri_display.rb', line 76 def display_class_info(klass, ri_reader) page do superclass = klass.superclass_string if superclass superclass = " < " + superclass else superclass = "" end @formatter.draw_line(klass.display_name + ": " + klass.full_name + superclass) display_flow(klass.comment) @formatter.draw_line unless klass.includes.empty? @formatter.blankline @formatter.display_heading("Includes:", 2, "") incs = [] klass.includes.each do |inc| inc_desc = ri_reader.find_class_by_name(inc.name) if inc_desc str = inc.name + "(" str << inc_desc.instance_methods.map{|m| m.name}.join(", ") str << ")" incs << str else incs << inc.name end end @formatter.wrap(incs.sort.join(', ')) end unless klass.constants.empty? @formatter.blankline @formatter.display_heading("Constants:", 2, "") len = 0 klass.constants.each { |c| len = c.name.length if c.name.length > len } len += 2 klass.constants.each do |c| @formatter.wrap(c.value, @formatter.indent+((c.name+":").ljust(len))) end end unless klass.class_methods.empty? @formatter.blankline @formatter.display_heading("Class methods:", 2, "") @formatter.wrap(klass.class_methods.map{|m| m.name}.sort.join(', ')) end unless klass.instance_methods.empty? @formatter.blankline @formatter.display_heading("Instance methods:", 2, "") @formatter.wrap(klass.instance_methods.map{|m| m.name}.sort.join(', ')) end unless klass.attributes.empty? @formatter.blankline @formatter.wrap("Attributes:", "") @formatter.wrap(klass.attributes.map{|a| a.name}.sort.join(', ')) end end end |
#display_class_list(namespaces) ⇒ Object
####################################################################
156 157 158 159 160 161 162 |
# File 'lib/rdoc/ri/ri_display.rb', line 156 def display_class_list(namespaces) page do puts "More than one class or module matched your request. You can refine" puts "your search by asking for information on one of:\n\n" @formatter.wrap(namespaces.map {|m| m.full_name}.join(", ")) end end |
#display_method_info(method) ⇒ Object
####################################################################
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rdoc/ri/ri_display.rb', line 58 def display_method_info(method) page do @formatter.draw_line(method.full_name) display_params(method) @formatter.draw_line display_flow(method.comment) if method.aliases && !method.aliases.empty? @formatter.blankline aka = "(also known as " aka << method.aliases.map {|a| a.name }.join(", ") aka << ")" @formatter.wrap(aka) end end end |
#display_method_list(methods) ⇒ Object
Display a list of method names
146 147 148 149 150 151 152 |
# File 'lib/rdoc/ri/ri_display.rb', line 146 def display_method_list(methods) page do puts "More than one method matched your request. You can refine" puts "your search by asking for information on one of:\n\n" @formatter.wrap(methods.map {|m| m.full_name} .join(", ")) end end |
#display_usage ⇒ Object
####################################################################
49 50 51 52 53 |
# File 'lib/rdoc/ri/ri_display.rb', line 49 def display_usage page do RI::Options::OptionList.usage(short_form=true) end end |
#list_known_classes(classes) ⇒ Object
####################################################################
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/rdoc/ri/ri_display.rb', line 166 def list_known_classes(classes) if classes.empty? warn_no_database else page do @formatter.draw_line("Known classes and modules") @formatter.blankline @formatter.wrap(classes.sort.join(", ")) end end end |
#list_known_names(names) ⇒ Object
####################################################################
180 181 182 183 184 185 186 187 188 |
# File 'lib/rdoc/ri/ri_display.rb', line 180 def list_known_names(names) if names.empty? warn_no_database else page do names.each {|n| @formatter.raw_print_line(n)} end end end |