Class: Fast::FindFromArgument
Overview
Allow the user to interpolate expressions from external stuff. Use ‘%1` in the expression and the Matcher#prepare_arguments will interpolate the argument in the expression.
Instance Attribute Summary collapse
-
#arguments ⇒ Object
writeonly
Sets the attribute arguments.
Attributes inherited from Find
Instance Method Summary collapse
-
#initialize(token) ⇒ FindFromArgument
constructor
A new instance of FindFromArgument.
- #match?(node) ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from Find
#==, #compare_symbol_or_head, #debug, #debug_match_recursive, #match_recursive
Constructor Details
#initialize(token) ⇒ FindFromArgument
Returns a new instance of FindFromArgument.
486 487 488 489 490 491 492 |
# File 'lib/fast.rb', line 486 def initialize(token) token = token.token if token.respond_to?(:token) raise 'You must define index' unless token @capture_argument = token.to_i - 1 raise 'Arguments start in one' if @capture_argument.negative? end |
Instance Attribute Details
#arguments=(value) ⇒ Object (writeonly)
Sets the attribute arguments
484 485 486 |
# File 'lib/fast.rb', line 484 def arguments=(value) @arguments = value end |
Instance Method Details
#match?(node) ⇒ Boolean
494 495 496 497 498 |
# File 'lib/fast.rb', line 494 def match?(node) raise 'You must define arguments to match' unless @arguments compare_symbol_or_head @arguments[@capture_argument], node end |
#to_s ⇒ Object
500 501 502 |
# File 'lib/fast.rb', line 500 def to_s "find_with_arg[\\#{@capture_argument}]" end |