Module: Locator::Index

Defined in:
lib/cucumber/pickles/locator/index.rb

Constant Summary collapse

INDEX_REGEX =
/(.*)?\[(.*)\]\s*$/

Class Method Summary collapse

Class Method Details

.execute(locator) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cucumber/pickles/locator/index.rb', line 7

def execute(locator)
  return [nil, nil] if locator.nil?

  matches = INDEX_REGEX.match(locator)

  return [locator, nil] unless matches

  text = matches.captures[0]
  index = matches.captures[1].to_i

  [text, index]
end