Module: Gapic::UriTemplate::Parser

Defined in:
lib/gapic/uri_template/parser.rb

Overview

A URI template parser. see https://tools.ietf.org/html/rfc6570 URI Template

Class Method Summary collapse

Class Method Details

.parse_arguments(uri_template) ⇒ Array<Array<String>] The arguments and their corresponding patterns

Parses the arguments out of URI template with their corresponding patterns

Parameters:

  • The (String)

    uri template to be parsed.

Returns:

  • (Array<Array<String>] The arguments and their corresponding patterns)

    Array] The arguments and their corresponding patterns



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gapic/uri_template/parser.rb', line 39

def self.parse_arguments uri_template
  arguments = []

  while (match = URI_TEMPLATE.match uri_template)
    # The String before the match needs to be added to the segments
    if match[:name]
      name = match[:name]
      template = match[:template] || ""
      arguments << [name, template]
    end
    uri_template = match.post_match
  end

  arguments
end