Class: SQLtorial::Directive

Inherits:
Object
  • Object
show all
Defined in:
lib/sqltorial/directives/directive.rb

Class Method Summary collapse

Class Method Details

.from_line(line) ⇒ Object



14
15
16
17
18
# File 'lib/sqltorial/directives/directive.rb', line 14

def from_line(line)
  @@directives.each do |directive_klass|
    return directive_klass.new(line) if directive_klass.regexp.match(line)
  end
end

.match(line) ⇒ Object



8
9
10
11
12
# File 'lib/sqltorial/directives/directive.rb', line 8

def match(line)
  @@directives.any? do |directive_klass|
    directive_klass.regexp.match(line)
  end
end

.register(directive_klass) ⇒ Object



4
5
6
# File 'lib/sqltorial/directives/directive.rb', line 4

def register(directive_klass)
  (@@directives ||= []) << directive_klass
end