Class: Gapic::PathPattern::PositionalSegment
- Inherits:
-
Object
- Object
- Gapic::PathPattern::PositionalSegment
- Defined in:
- lib/gapic/path_pattern/segment.rb
Overview
A positional segment in a path pattern. positional segments have a pattern of wildcards and do not carry a name
Instance Attribute Summary collapse
-
#pattern ⇒ String
readonly
The pattern of the segment, for the positional segment it is also a pattern of its resource.
-
#position ⇒ Integer
readonly
The argument position of this segment i.e.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#arguments ⇒ Array<String>
Names of the segment's arguments.
-
#expected_path_for_dummy_values(start_index) ⇒ String
Returns a segment's pattern filled with dummy values names of the values are generated starting from the index provided.
-
#initialize(position, pattern) ⇒ PositionalSegment
constructor
A new instance of PositionalSegment.
-
#nontrivial_resource_pattern? ⇒ Boolean
Whether the segment provides a nontrivial resource pattern.
-
#path_string ⇒ String
Path string for this segment.
-
#pattern_template ⇒ String
A pattern template for this segment.
-
#positional? ⇒ Boolean
Whether the segment is positional.
-
#provides_arguments? ⇒ Boolean
Whether the segment provides arguments.
-
#resource_pattern? ⇒ Boolean
Whether the segment provides a resource pattern.
Constructor Details
#initialize(position, pattern) ⇒ PositionalSegment
Returns a new instance of PositionalSegment.
36 37 38 39 40 |
# File 'lib/gapic/path_pattern/segment.rb', line 36 def initialize position, pattern @type = :positional @position = position @pattern = pattern end |
Instance Attribute Details
#pattern ⇒ String (readonly)
Returns The pattern of the segment, for the positional segment it is also a pattern of its resource.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/gapic/path_pattern/segment.rb', line 31 class PositionalSegment attr_reader :type attr_reader :position attr_reader :pattern def initialize position, pattern @type = :positional @position = position @pattern = pattern end ## # Whether the segment is positional # @return [Boolean] def positional? true end ## # Whether the segment provides a resource pattern # @return [Boolean] def resource_pattern? true 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? true end ## # Names of the segment's arguments # @return [Array<String>] def arguments [position.to_s] end ## # Returns a segment's pattern filled with dummy values # names of the values are generated starting from the index provided # @param start_index [Integer] a starting index for dummy value generation # @return [String] a pattern filled with dummy values def expected_path_for_dummy_values start_index "value#{start_index}" end ## # Path string for this segment # @return [String] def path_string "\#{#{position}}" end ## # A pattern template for this segment # @return [String] def pattern_template pattern end # @private def == other return false unless other.is_a? self.class (pattern == other.pattern && position == other.position) end end |
#position ⇒ Integer (readonly)
Returns The argument position of this segment i.e. it's position if we remove all non-positional segments from the pattern.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/gapic/path_pattern/segment.rb', line 31 class PositionalSegment attr_reader :type attr_reader :position attr_reader :pattern def initialize position, pattern @type = :positional @position = position @pattern = pattern end ## # Whether the segment is positional # @return [Boolean] def positional? true end ## # Whether the segment provides a resource pattern # @return [Boolean] def resource_pattern? true 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? true end ## # Names of the segment's arguments # @return [Array<String>] def arguments [position.to_s] end ## # Returns a segment's pattern filled with dummy values # names of the values are generated starting from the index provided # @param start_index [Integer] a starting index for dummy value generation # @return [String] a pattern filled with dummy values def expected_path_for_dummy_values start_index "value#{start_index}" end ## # Path string for this segment # @return [String] def path_string "\#{#{position}}" end ## # A pattern template for this segment # @return [String] def pattern_template pattern end # @private def == other return false unless other.is_a? self.class (pattern == other.pattern && position == other.position) end end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
32 33 34 |
# File 'lib/gapic/path_pattern/segment.rb', line 32 def type @type end |
Instance Method Details
#arguments ⇒ Array<String>
Names of the segment's arguments
73 74 75 |
# File 'lib/gapic/path_pattern/segment.rb', line 73 def arguments [position.to_s] end |
#expected_path_for_dummy_values(start_index) ⇒ String
Returns a segment's pattern filled with dummy values names of the values are generated starting from the index provided
82 83 84 |
# File 'lib/gapic/path_pattern/segment.rb', line 82 def expected_path_for_dummy_values start_index "value#{start_index}" end |
#nontrivial_resource_pattern? ⇒ Boolean
Whether the segment provides a nontrivial resource pattern
59 60 61 |
# File 'lib/gapic/path_pattern/segment.rb', line 59 def nontrivial_resource_pattern? false end |
#path_string ⇒ String
Path string for this segment
89 90 91 |
# File 'lib/gapic/path_pattern/segment.rb', line 89 def path_string "\#{#{position}}" end |
#pattern_template ⇒ String
A pattern template for this segment
96 97 98 |
# File 'lib/gapic/path_pattern/segment.rb', line 96 def pattern_template pattern end |
#positional? ⇒ Boolean
Whether the segment is positional
45 46 47 |
# File 'lib/gapic/path_pattern/segment.rb', line 45 def positional? true end |
#provides_arguments? ⇒ Boolean
Whether the segment provides arguments
66 67 68 |
# File 'lib/gapic/path_pattern/segment.rb', line 66 def provides_arguments? true end |
#resource_pattern? ⇒ Boolean
Whether the segment provides a resource pattern
52 53 54 |
# File 'lib/gapic/path_pattern/segment.rb', line 52 def resource_pattern? true end |