Class: GreenPepper::FreeTextKeyword
- Inherits:
-
Object
- Object
- GreenPepper::FreeTextKeyword
- Defined in:
- lib/greenpepper/freetext.rb
Direct Known Subclasses
AskKeyword, CheckKeyword, GivenKeyword, ThenKeyword, WhenKeyword
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
- #args(action) ⇒ Object
-
#initialize(regex, block, convert) ⇒ FreeTextKeyword
constructor
A new instance of FreeTextKeyword.
- #match?(action) ⇒ Boolean
Constructor Details
#initialize(regex, block, convert) ⇒ FreeTextKeyword
Returns a new instance of FreeTextKeyword.
95 96 97 98 99 |
# File 'lib/greenpepper/freetext.rb', line 95 def initialize(regex, block, convert) raise ArgumentError.new unless regex.is_a? Regexp raise ArgumentError.new unless block.is_a? Proc @regex, @block, @convert = regex, block, convert end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
92 93 94 |
# File 'lib/greenpepper/freetext.rb', line 92 def block @block end |
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
92 93 94 |
# File 'lib/greenpepper/freetext.rb', line 92 def regex @regex end |
#result ⇒ Object
Returns the value of attribute result.
93 94 95 |
# File 'lib/greenpepper/freetext.rb', line 93 def result @result end |
Instance Method Details
#args(action) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/greenpepper/freetext.rb', line 105 def args(action) args = @regex.match(action)[1..-1] args.collect!{ |arg| TypeConverter.instance.convert_string(arg) } if @convert args end |
#match?(action) ⇒ Boolean
101 102 103 |
# File 'lib/greenpepper/freetext.rb', line 101 def match?(action) @regex === action end |