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.
554 555 556 557 558 559 560 |
# File 'lib/fast.rb', line 554 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
552 553 554 |
# File 'lib/fast.rb', line 552 def arguments=(value) @arguments = value end |
Instance Method Details
#match?(node) ⇒ Boolean
562 563 564 565 566 |
# File 'lib/fast.rb', line 562 def match?(node) raise 'You must define arguments to match' unless @arguments compare_symbol_or_head @arguments[@capture_argument], node end |
#to_s ⇒ Object
568 569 570 |
# File 'lib/fast.rb', line 568 def to_s "find_with_arg[\\#{@capture_argument}]" end |