lib/tribe_challenge/tribe_bundler.rb
def parse(line)
    return false if line.nil?

    line.downcase!
    # pick up the different totals and codes from the input for processing
    valid_codes = TribeBundles.codes
    regex_source = /([\d]*) (#{valid_codes.join('|')})/
    entries = line.scan(Regexp.new(regex_source))
    result = []
    entries.each { |entry| result << bundle(entry.first, entry.last.to_sym) }
    return result
  end
##
# Parse basic input that comes in the form of a line of requests.
# @example
# parse('10 IMG 15 FLAC 13 VID')
#
# @param [String] line, The line to parse.
#
# @return [Hash], the bundles of media items that correspond to the given
# line.
##
Parse basic input that comes in the form of a line of requests.
Parse basic input that comes in the form of a line of requests .
def parse(line)
    return false if line.nil?
    line.downcase!
    valid_codes = TribeBundles.codes
    regex_source = /([\d]*) (#{valid_codes.join('|')})/
    entries = line.scan(Regexp.new(regex_source))
    result = []
    entries.each { |entry| result << bundle(entry.first, entry.last.to_sym) }
    return result
  end
def parse ( line ) return false if line . nil? line . downcase! valid_codes = TribeBundles . codes regex_source = / ([ \d ]*) ( #{ valid_codes . join ( '|' ) } ) / entries = line . scan ( Regexp . new ( regex_source ) ) result = [ ] entries . each { | entry | result << bundle ( entry . first , entry . last . to_sym ) } return result end
Parse basic input that comes in the form of a line of requests.
Parse basic input that comes in the form of a line of requests .
# pick up the different totals and codes from the input for processing
, the bundles of media items that correspond to the given line.
the bundles of media items that correspond to the given line .
Hash
line
line, The line to parse.
line The line to parse .
example
None