Class: SQLtorial::ValidColumnDirective
- Inherits:
-
Object
- Object
- SQLtorial::ValidColumnDirective
- Defined in:
- lib/sqltorial/directives/valid_column_directive.rb
Constant Summary collapse
- REGEXP =
/^\s*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) ⇒ ValidColumnDirective
constructor
A new instance of ValidColumnDirective.
- #inspect ⇒ Object
- #validate(result) ⇒ Object
Constructor Details
#initialize(line) ⇒ ValidColumnDirective
Returns a new instance of ValidColumnDirective.
12 13 14 15 16 17 |
# File 'lib/sqltorial/directives/valid_column_directive.rb', line 12 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.
11 12 13 |
# File 'lib/sqltorial/directives/valid_column_directive.rb', line 11 def column @column end |
#matcher ⇒ Object (readonly)
Returns the value of attribute matcher.
11 12 13 |
# File 'lib/sqltorial/directives/valid_column_directive.rb', line 11 def matcher @matcher end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
11 12 13 |
# File 'lib/sqltorial/directives/valid_column_directive.rb', line 11 def op @op end |
Class Method Details
.regexp ⇒ Object
6 7 8 |
# File 'lib/sqltorial/directives/valid_column_directive.rb', line 6 def regexp REGEXP end |
Instance Method Details
#inspect ⇒ Object
24 25 26 |
# File 'lib/sqltorial/directives/valid_column_directive.rb', line 24 def inspect [column, op, matcher].join(" ") end |
#validate(result) ⇒ Object
19 20 21 22 |
# File 'lib/sqltorial/directives/valid_column_directive.rb', line 19 def validate(result) md = matcher.match(result[column]) op == '=' ? !md.nil? : md.nil? end |