Class: Gm::Notepad::InputHandlers::QueryTableNamesHandler
- Inherits:
-
DefaultHandler
- Object
- DefaultHandler
- Gm::Notepad::InputHandlers::QueryTableNamesHandler
- Defined in:
- lib/gm/notepad/input_handlers/query_table_names_handler.rb
Constant Summary collapse
- QUERY_TABLE_NAMES_PREFIX =
'+'.freeze
- WITH_GREP_REGEXP =
%r{(?<declaration>\/(?<grep>[^\/]+)/)}
Instance Attribute Summary collapse
-
#grep ⇒ Object
Returns the value of attribute grep.
Attributes inherited from DefaultHandler
#expand_line, #input, #table_registry, #to_filesystem, #to_interactive, #to_output
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from DefaultHandler
build_if_handled, #each_line_with_parameters, #initialize
Constructor Details
This class inherits a constructor from Gm::Notepad::InputHandlers::DefaultHandler
Instance Attribute Details
#grep ⇒ Object
Returns the value of attribute grep.
31 32 33 |
# File 'lib/gm/notepad/input_handlers/query_table_names_handler.rb', line 31 def grep @grep end |
Class Method Details
.handles?(input:) ⇒ Boolean
8 9 10 11 12 13 14 15 16 |
# File 'lib/gm/notepad/input_handlers/query_table_names_handler.rb', line 8 def self.handles?(input:) # Does not have the table prefix return false unless input[0] == QUERY_TABLE_NAMES_PREFIX # It is only the table prefix return true if input == QUERY_TABLE_NAMES_PREFIX # It is querying all tables by way of grep return true if input[0..1] == "#{QUERY_TABLE_NAMES_PREFIX}/" false end |
Instance Method Details
#after_initialize! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gm/notepad/input_handlers/query_table_names_handler.rb', line 19 def after_initialize! self. = false self.to_output = false self.to_interactive = true line = input[1..-1] if match = WITH_GREP_REGEXP.match(line) line = line.sub(match[:declaration], '') self.grep = match[:grep] end end |
#lines ⇒ Object
33 34 35 36 37 |
# File 'lib/gm/notepad/input_handlers/query_table_names_handler.rb', line 33 def lines table_names = table_registry.table_names return table_names unless grep table_names.grep(%r{#{grep}}) end |