Class: AWSCDK::Assertions::Capture
- Inherits:
-
Matcher
- Object
- Matcher
- AWSCDK::Assertions::Capture
- Defined in:
- assertions/capture.rb
Overview
Capture values while matching templates.
Using an instance of this class within a Matcher will capture the matching value.
The as*() APIs on the instance can be used to get the captured value.
Class Method Summary collapse
Instance Method Summary collapse
-
#_next ⇒ Boolean
When multiple results are captured, move the iterator to the next result.
-
#as_array ⇒ Array<Object>
Retrieve the captured value as an array.
-
#as_boolean ⇒ Boolean
Retrieve the captured value as a boolean.
-
#as_number ⇒ Numeric
Retrieve the captured value as a number.
-
#as_object ⇒ Hash{String => Object}
Retrieve the captured value as a JSON object.
-
#as_string ⇒ String
Retrieve the captured value as a string.
-
#initialize(pattern = nil) ⇒ Capture
constructor
Initialize a new capture.
-
#name ⇒ String
A name for the matcher.
-
#test(actual) ⇒ AWSCDK::Assertions::MatchResult
Test whether a target matches the provided pattern.
Constructor Details
#initialize(pattern = nil) ⇒ Capture
Initialize a new capture.
14 15 16 17 |
# File 'assertions/capture.rb', line 14 def initialize(pattern = nil) Jsii::Type.check_type(pattern, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "pattern") unless pattern.nil? Jsii::Object.instance_method(:initialize).bind(self).call(pattern) end |
Class Method Details
.jsii_overridable_methods ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'assertions/capture.rb', line 19 def self.jsii_overridable_methods { :name => { kind: :property, name: "name", is_optional: false }, :test => { kind: :method, name: "test", is_optional: false }, :as_array => { kind: :method, name: "asArray", is_optional: false }, :as_boolean => { kind: :method, name: "asBoolean", is_optional: false }, :as_number => { kind: :method, name: "asNumber", is_optional: false }, :as_object => { kind: :method, name: "asObject", is_optional: false }, :as_string => { kind: :method, name: "asString", is_optional: false }, :_next => { kind: :method, name: "next", is_optional: false }, } end |
Instance Method Details
#_next ⇒ Boolean
When multiple results are captured, move the iterator to the next result.
101 102 103 |
# File 'assertions/capture.rb', line 101 def _next() jsii_call_method("next", []) end |
#as_array ⇒ Array<Object>
Retrieve the captured value as an array.
An error is generated if no value is captured or if the value is not an array.
58 59 60 |
# File 'assertions/capture.rb', line 58 def as_array() jsii_call_method("asArray", []) end |
#as_boolean ⇒ Boolean
Retrieve the captured value as a boolean.
An error is generated if no value is captured or if the value is not a boolean.
67 68 69 |
# File 'assertions/capture.rb', line 67 def as_boolean() jsii_call_method("asBoolean", []) end |
#as_number ⇒ Numeric
Retrieve the captured value as a number.
An error is generated if no value is captured or if the value is not a number.
76 77 78 |
# File 'assertions/capture.rb', line 76 def as_number() jsii_call_method("asNumber", []) end |
#as_object ⇒ Hash{String => Object}
Retrieve the captured value as a JSON object.
An error is generated if no value is captured or if the value is not an object.
85 86 87 |
# File 'assertions/capture.rb', line 85 def as_object() jsii_call_method("asObject", []) end |
#as_string ⇒ String
Retrieve the captured value as a string.
An error is generated if no value is captured or if the value is not a string.
94 95 96 |
# File 'assertions/capture.rb', line 94 def as_string() jsii_call_method("asString", []) end |
#name ⇒ String
A name for the matcher.
This is collected as part of the result and may be presented to the user.
37 38 39 |
# File 'assertions/capture.rb', line 37 def name() jsii_get_property("name") end |
#test(actual) ⇒ AWSCDK::Assertions::MatchResult
Test whether a target matches the provided pattern.
Every Matcher must implement this method. This method will be invoked by the assertions framework. Do not call this method directly.
48 49 50 51 |
# File 'assertions/capture.rb', line 48 def test(actual) Jsii::Type.check_type(actual, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "actual") jsii_call_method("test", [actual]) end |