Class: AWSCDK::Duration
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::Duration
- Defined in:
- duration.rb
Overview
Represents a length of time.
The amount can be specified either as a literal value (e.g: 10) which
cannot be negative, or as an unresolved number token.
When the amount is passed as a token, unit conversion is not possible.
Class Method Summary collapse
-
.days(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of days.
-
.hours(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of hours.
- .jsii_overridable_methods ⇒ Object
-
.millis(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of milliseconds.
-
.minutes(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of minutes.
-
.parse(duration) ⇒ AWSCDK::Duration
Parse a period formatted according to the ISO 8601 standard.
-
.seconds(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of seconds.
Instance Method Summary collapse
-
#format_token_to_number ⇒ String
Returns stringified number of duration.
-
#initialize(*args) ⇒ Duration
constructor
A new instance of Duration.
-
#is_unresolved ⇒ Boolean
Checks if duration is a token or a resolvable object.
-
#minus(rhs) ⇒ AWSCDK::Duration
Substract two Durations together.
-
#plus(rhs) ⇒ AWSCDK::Duration
Add two Durations together.
-
#to_days(opts = nil) ⇒ Numeric
Return the total number of days in this Duration.
-
#to_hours(opts = nil) ⇒ Numeric
Return the total number of hours in this Duration.
-
#to_human_string ⇒ String
Turn this duration into a human-readable string.
-
#to_iso_string ⇒ String
Return an ISO 8601 representation of this period.
-
#to_milliseconds(opts = nil) ⇒ Numeric
Return the total number of milliseconds in this Duration.
-
#to_minutes(opts = nil) ⇒ Numeric
Return the total number of minutes in this Duration.
-
#to_seconds(opts = nil) ⇒ Numeric
Return the total number of seconds in this Duration.
-
#to_string ⇒ String
Returns a string representation of this
Duration. -
#unit_label ⇒ String
Returns unit of the duration.
Constructor Details
#initialize(*args) ⇒ Duration
Returns a new instance of Duration.
13 14 15 |
# File 'duration.rb', line 13 def initialize(*args) raise NoMethodError, "aws-cdk-lib.Duration does not have a visible constructor; use the provided factory methods" end |
Class Method Details
.days(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of days.
39 40 41 42 |
# File 'duration.rb', line 39 def self.days(amount) Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount") Jsii::Kernel.instance.call_static("aws-cdk-lib.Duration", "days", [amount]) end |
.hours(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of hours.
48 49 50 51 |
# File 'duration.rb', line 48 def self.hours(amount) Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount") Jsii::Kernel.instance.call_static("aws-cdk-lib.Duration", "hours", [amount]) end |
.jsii_overridable_methods ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'duration.rb', line 17 def self.jsii_overridable_methods { :format_token_to_number => { kind: :method, name: "formatTokenToNumber", is_optional: false }, :is_unresolved => { kind: :method, name: "isUnresolved", is_optional: false }, :minus => { kind: :method, name: "minus", is_optional: false }, :plus => { kind: :method, name: "plus", is_optional: false }, :to_days => { kind: :method, name: "toDays", is_optional: false }, :to_hours => { kind: :method, name: "toHours", is_optional: false }, :to_human_string => { kind: :method, name: "toHumanString", is_optional: false }, :to_iso_string => { kind: :method, name: "toIsoString", is_optional: false }, :to_milliseconds => { kind: :method, name: "toMilliseconds", is_optional: false }, :to_minutes => { kind: :method, name: "toMinutes", is_optional: false }, :to_seconds => { kind: :method, name: "toSeconds", is_optional: false }, :to_string => { kind: :method, name: "toString", is_optional: false }, :unit_label => { kind: :method, name: "unitLabel", is_optional: false }, } end |
.millis(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of milliseconds.
57 58 59 60 |
# File 'duration.rb', line 57 def self.millis(amount) Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount") Jsii::Kernel.instance.call_static("aws-cdk-lib.Duration", "millis", [amount]) end |
.minutes(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of minutes.
66 67 68 69 |
# File 'duration.rb', line 66 def self.minutes(amount) Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount") Jsii::Kernel.instance.call_static("aws-cdk-lib.Duration", "minutes", [amount]) end |
.parse(duration) ⇒ AWSCDK::Duration
Parse a period formatted according to the ISO 8601 standard.
Days are the largest ISO duration supported, i.e., weeks, months, and years are not supported.
82 83 84 85 |
# File 'duration.rb', line 82 def self.parse(duration) Jsii::Type.check_type(duration, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "duration") Jsii::Kernel.instance.call_static("aws-cdk-lib.Duration", "parse", [duration]) end |
.seconds(amount) ⇒ AWSCDK::Duration
Create a Duration representing an amount of seconds.
91 92 93 94 |
# File 'duration.rb', line 91 def self.seconds(amount) Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount") Jsii::Kernel.instance.call_static("aws-cdk-lib.Duration", "seconds", [amount]) end |
Instance Method Details
#format_token_to_number ⇒ String
Returns stringified number of duration.
99 100 101 |
# File 'duration.rb', line 99 def format_token_to_number() jsii_call_method("formatTokenToNumber", []) end |
#is_unresolved ⇒ Boolean
Checks if duration is a token or a resolvable object.
106 107 108 |
# File 'duration.rb', line 106 def is_unresolved() jsii_call_method("isUnresolved", []) end |
#minus(rhs) ⇒ AWSCDK::Duration
Substract two Durations together.
114 115 116 117 |
# File 'duration.rb', line 114 def minus(rhs) Jsii::Type.check_type(rhs, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "rhs") jsii_call_method("minus", [rhs]) end |
#plus(rhs) ⇒ AWSCDK::Duration
Add two Durations together.
123 124 125 126 |
# File 'duration.rb', line 123 def plus(rhs) Jsii::Type.check_type(rhs, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "rhs") jsii_call_method("plus", [rhs]) end |
#to_days(opts = nil) ⇒ Numeric
Return the total number of days in this Duration.
132 133 134 135 136 |
# File 'duration.rb', line 132 def to_days(opts = nil) opts = opts.is_a?(Hash) ? ::AWSCDK::TimeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5UaW1lQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil? jsii_call_method("toDays", [opts]) end |
#to_hours(opts = nil) ⇒ Numeric
Return the total number of hours in this Duration.
142 143 144 145 146 |
# File 'duration.rb', line 142 def to_hours(opts = nil) opts = opts.is_a?(Hash) ? ::AWSCDK::TimeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5UaW1lQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil? jsii_call_method("toHours", [opts]) end |
#to_human_string ⇒ String
Turn this duration into a human-readable string.
151 152 153 |
# File 'duration.rb', line 151 def to_human_string() jsii_call_method("toHumanString", []) end |
#to_iso_string ⇒ String
Return an ISO 8601 representation of this period.
159 160 161 |
# File 'duration.rb', line 159 def to_iso_string() jsii_call_method("toIsoString", []) end |
#to_milliseconds(opts = nil) ⇒ Numeric
Return the total number of milliseconds in this Duration.
167 168 169 170 171 |
# File 'duration.rb', line 167 def to_milliseconds(opts = nil) opts = opts.is_a?(Hash) ? ::AWSCDK::TimeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5UaW1lQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil? jsii_call_method("toMilliseconds", [opts]) end |
#to_minutes(opts = nil) ⇒ Numeric
Return the total number of minutes in this Duration.
177 178 179 180 181 |
# File 'duration.rb', line 177 def to_minutes(opts = nil) opts = opts.is_a?(Hash) ? ::AWSCDK::TimeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5UaW1lQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil? jsii_call_method("toMinutes", [opts]) end |
#to_seconds(opts = nil) ⇒ Numeric
Return the total number of seconds in this Duration.
187 188 189 190 191 |
# File 'duration.rb', line 187 def to_seconds(opts = nil) opts = opts.is_a?(Hash) ? ::AWSCDK::TimeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5UaW1lQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil? jsii_call_method("toSeconds", [opts]) end |
#to_string ⇒ String
Returns a string representation of this Duration.
This is never the right function to use when you want to use the Duration
object in a template. Use to_seconds(), to_minutes(), to_days(), etc. instead.
199 200 201 |
# File 'duration.rb', line 199 def to_string() jsii_call_method("toString", []) end |
#unit_label ⇒ String
Returns unit of the duration.
206 207 208 |
# File 'duration.rb', line 206 def unit_label() jsii_call_method("unitLabel", []) end |