Class: Redcar::FilterCommand::OutputFormat
- Inherits:
-
Object
- Object
- Redcar::FilterCommand::OutputFormat
- Defined in:
- lib/filter_command/output_format.rb
Overview
A means of displaying text. New output formats can be defined by extending OutputFormat and implementing the ‘type` and `format` methods
Direct Known Subclasses
Class Method Summary collapse
-
.formats ⇒ Object
A Hash of all known formats.
-
.supported_types(*names) ⇒ Object
The generator method for ‘formats`.
Instance Method Summary collapse
-
#edit_tab_focussed? ⇒ Boolean
A check whether an editable tab is currently focussed in Redcar.
-
#format(text, type) ⇒ Object
Where the work happens! This method is called when there is text to be processed.
-
#missing_edit_tab(type) ⇒ Object
The error message indicating that the currently selected output format requires the current tab to be an editable tab.
-
#newline ⇒ Object
A newline character (platform-specific).
-
#tab ⇒ Object
The currently focussed tab.
-
#type ⇒ Object
A name or list of names of supported output formats for the current class.
Class Method Details
.formats ⇒ Object
A Hash of all known formats
9 10 11 |
# File 'lib/filter_command/output_format.rb', line 9 def self.formats @types ||= {} end |
.supported_types(*names) ⇒ Object
The generator method for ‘formats`
14 15 16 17 18 19 20 21 |
# File 'lib/filter_command/output_format.rb', line 14 def self.supported_types(*names) if names.any? names.each {|n| OutputFormat.formats[n] = self } @supported_types = supported_types + names else @supported_types ||= [] end end |
Instance Method Details
#edit_tab_focussed? ⇒ Boolean
A check whether an editable tab is currently focussed in Redcar
24 25 26 |
# File 'lib/filter_command/output_format.rb', line 24 def edit_tab_focussed? tab and tab.is_a?(Redcar::EditTab) end |
#format(text, type) ⇒ Object
Where the work happens! This method is called when there is text to be processed
57 58 59 |
# File 'lib/filter_command/output_format.rb', line 57 def format text, type raise "A format method has not been defined by #{self.class.name}" end |
#missing_edit_tab(type) ⇒ Object
The error message indicating that the currently selected output format requires the current tab to be an editable tab
45 46 47 |
# File 'lib/filter_command/output_format.rb', line 45 def missing_edit_tab type Redcar::Application::Dialog.("To use the #{type} output format, the current tab must be an edit tab.") end |
#newline ⇒ Object
A newline character (platform-specific)
35 36 37 38 39 40 41 |
# File 'lib/filter_command/output_format.rb', line 35 def newline if Redcar.platform == :win newline = "\r\n" else newline = "\n" end end |
#tab ⇒ Object
The currently focussed tab
29 30 31 32 |
# File 'lib/filter_command/output_format.rb', line 29 def tab win = Redcar.app.focussed_window win.focussed_notebook_tab end |
#type ⇒ Object
A name or list of names of supported output formats for the current class
50 51 52 |
# File 'lib/filter_command/output_format.rb', line 50 def type raise "A name has not been defined by #{self.class.name}. This text is displayed in the Filter Command speedbar." end |