Class: Gapic::PathPattern::CollectionIdSegment

Inherits:
Object
  • Object
show all
Defined in:
lib/gapic/path_pattern/segment.rb

Overview

A CollectionId segment in a path template. CollectionId segments are basically string literals

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ CollectionIdSegment

Returns a new instance of CollectionIdSegment.



301
302
303
304
# File 'lib/gapic/path_pattern/segment.rb', line 301

def initialize pattern
  @type     = :collection_id
  @pattern  = pattern
end

Instance Attribute Details

#patternString (readonly)

Returns The pattern of the segment, for the positional segment it is also a pattern of its resource.

Returns:

  • (String)

    The pattern of the segment, for the positional segment it is also a pattern of its resource



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/gapic/path_pattern/segment.rb', line 297

class CollectionIdSegment
  attr_reader :type
  attr_reader :pattern

  def initialize pattern
    @type     = :collection_id
    @pattern  = pattern
  end

  ##
  # Whether the segment is positional
  # @return [Boolean]
  def positional?
    false
  end

  ##
  # Whether the segment provides a resource pattern
  # @return [Boolean]
  def resource_pattern?
    false
  end

  ##
  # Whether the segment provides a nontrivial resource pattern
  # @return [Boolean]
  def nontrivial_resource_pattern?
    false
  end

  ##
  # Whether the segment provides arguments
  # @return [Boolean]
  def provides_arguments?
    false
  end

  ##
  # Path string for this segment
  # @return [String]
  def path_string
    pattern
  end

  ##
  # A pattern template for this segment
  # @return [String]
  def pattern_template
    pattern
  end

  ##
  # Whether the segment is a resource id segment
  # @return [Boolean]
  def resource_id_segment?
    false
  end

  ##
  # The difference between `simplified_pattern` and `pattern`
  # does not exist for the CollectionId segments
  # @return [String]
  def simplified_pattern
    pattern
  end

  ##
  # Creates a string with a regex representation of this segment's pattern
  # @return [String]
  def to_regex_str
    pattern
  end

  # @private
  def == other
    return false unless other.is_a? self.class

    (pattern == other.pattern)
  end
end

#typeObject (readonly)

Returns the value of attribute type.



298
299
300
# File 'lib/gapic/path_pattern/segment.rb', line 298

def type
  @type
end

Instance Method Details

#nontrivial_resource_pattern?Boolean

Whether the segment provides a nontrivial resource pattern

Returns:

  • (Boolean)


323
324
325
# File 'lib/gapic/path_pattern/segment.rb', line 323

def nontrivial_resource_pattern?
  false
end

#path_stringString

Path string for this segment

Returns:

  • (String)


337
338
339
# File 'lib/gapic/path_pattern/segment.rb', line 337

def path_string
  pattern
end

#pattern_templateString

A pattern template for this segment

Returns:

  • (String)


344
345
346
# File 'lib/gapic/path_pattern/segment.rb', line 344

def pattern_template
  pattern
end

#positional?Boolean

Whether the segment is positional

Returns:

  • (Boolean)


309
310
311
# File 'lib/gapic/path_pattern/segment.rb', line 309

def positional?
  false
end

#provides_arguments?Boolean

Whether the segment provides arguments

Returns:

  • (Boolean)


330
331
332
# File 'lib/gapic/path_pattern/segment.rb', line 330

def provides_arguments?
  false
end

#resource_id_segment?Boolean

Whether the segment is a resource id segment

Returns:

  • (Boolean)


351
352
353
# File 'lib/gapic/path_pattern/segment.rb', line 351

def resource_id_segment?
  false
end

#resource_pattern?Boolean

Whether the segment provides a resource pattern

Returns:

  • (Boolean)


316
317
318
# File 'lib/gapic/path_pattern/segment.rb', line 316

def resource_pattern?
  false
end

#simplified_patternString

The difference between simplified_pattern and pattern does not exist for the CollectionId segments

Returns:

  • (String)


359
360
361
# File 'lib/gapic/path_pattern/segment.rb', line 359

def simplified_pattern
  pattern
end

#to_regex_strString

Creates a string with a regex representation of this segment's pattern

Returns:

  • (String)


366
367
368
# File 'lib/gapic/path_pattern/segment.rb', line 366

def to_regex_str
  pattern
end