class ListNesting
Public Class Methods
new(match)
click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 24 def initialize(match) @match = match # gets an array in the nesting format that nest_match_attributes understands to interrogate nested object and array data grouping = [] nesting = match minimalListRegex = %r{(?:#{HAVE_ALTERNATION.split('/').join('|')})\s+(?:(a list of)\s+)?(?:a|an|(?:(#{FEWER_MORE_THAN_SYNONYM})\s+)?(#{INT_AS_WORDS_SYNONYM}|\d+))\s+(#{FIELD_NAME_SYNONYM})} maximalListRegex = %r{(?:#{HAVE_ALTERNATION.split('/').join('|')})\s+(?:(a list of)\s+)?(?:a|an|(?:(#{FEWER_MORE_THAN_SYNONYM})\s+)?(#{INT_AS_WORDS_SYNONYM}|\d+))\s+(#{MAXIMAL_FIELD_NAME_SYNONYM})} while matches = minimalListRegex.match(nesting) nextMatches = minimalListRegex.match(nesting[matches.end(0), nesting.length]) matches = maximalListRegex.match(nextMatches.nil? ? nesting : nesting[0, matches.end(0) + nextMatches.begin(0)]) nesting = nesting[matches.end(0), nesting.length] if matches[1].nil? then if matches[3].nil? then level = { type: 'single', key: matches[4], root: false } else level = { type: 'multiple', key: matches[4], comparison: ListCountComparison.new(matches[2], matches[3]), root: false } end else level = { type: 'list', key: matches[4], comparison: ListCountComparison.new(matches[2], matches[3]), root: false } end grouping.push(level) end @grouping = grouping.reverse end
Public Instance Methods
grouping()
click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 73 def grouping @grouping end
match()
click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 69 def match return @match end
push(node)
click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 65 def push(node) @grouping.push(node) end