Class: SQLtorial::RegexpDirective
- Inherits:
-
Object
- Object
- SQLtorial::RegexpDirective
- Defined in:
- lib/sqltorial/regexp_directive.rb
Constant Summary collapse
- REGEXP =
/^ DIRECTIVE:\s*(\S+)\s+(\S+)\s+(.+)/
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#matcher ⇒ Object
readonly
Returns the value of attribute matcher.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(line) ⇒ RegexpDirective
constructor
A new instance of RegexpDirective.
- #inspect ⇒ Object
- #validate(result) ⇒ Object
Constructor Details
#initialize(line) ⇒ RegexpDirective
Returns a new instance of RegexpDirective.
13 14 15 16 17 18 |
# File 'lib/sqltorial/regexp_directive.rb', line 13 def initialize(line) _, column, op, matcher = REGEXP.match(line).to_a @column = column.to_sym @op = op @matcher = Regexp.new(matcher) end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
12 13 14 |
# File 'lib/sqltorial/regexp_directive.rb', line 12 def column @column end |
#matcher ⇒ Object (readonly)
Returns the value of attribute matcher.
12 13 14 |
# File 'lib/sqltorial/regexp_directive.rb', line 12 def matcher @matcher end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
12 13 14 |
# File 'lib/sqltorial/regexp_directive.rb', line 12 def op @op end |
Class Method Details
.regexp ⇒ Object
7 8 9 |
# File 'lib/sqltorial/regexp_directive.rb', line 7 def regexp REGEXP end |
Instance Method Details
#inspect ⇒ Object
25 26 27 |
# File 'lib/sqltorial/regexp_directive.rb', line 25 def inspect [column, op, matcher].join(" ") end |
#validate(result) ⇒ Object
20 21 22 23 |
# File 'lib/sqltorial/regexp_directive.rb', line 20 def validate(result) md = matcher.match(result[column]) op == '=' ? !md.nil? : md.nil? end |