Class: AWSCDK::Size

Inherits:
Jsii::Object
  • Object
show all
Defined in:
size.rb

Overview

Represents the amount of digital storage.

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Size

Returns a new instance of Size.

Raises:

  • (NoMethodError)


13
14
15
# File 'size.rb', line 13

def initialize(*args)
  raise NoMethodError, "aws-cdk-lib.Size does not have a visible constructor; use the provided factory methods"
end

Class Method Details

.bytes(amount) ⇒ AWSCDK::Size

Create a Storage representing an amount bytes.

Parameters:

  • amount (Numeric)

    the amount of bytes to be represented.

Returns:

  • (AWSCDK::Size)

    a new Size instance



33
34
35
36
# File 'size.rb', line 33

def self.bytes(amount)
  Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Size", "bytes", [amount])
end

.gibibytes(amount) ⇒ AWSCDK::Size

Create a Storage representing an amount gibibytes.

1 GiB = 1024 MiB

Parameters:

  • amount (Numeric)

    the amount of gibibytes to be represented.

Returns:

  • (AWSCDK::Size)

    a new Size instance



44
45
46
47
# File 'size.rb', line 44

def self.gibibytes(amount)
  Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Size", "gibibytes", [amount])
end

.jsii_overridable_methodsObject



17
18
19
20
21
22
23
24
25
26
27
# File 'size.rb', line 17

def self.jsii_overridable_methods
  {
    :is_unresolved => { kind: :method, name: "isUnresolved", is_optional: false },
    :to_bytes => { kind: :method, name: "toBytes", is_optional: false },
    :to_gibibytes => { kind: :method, name: "toGibibytes", is_optional: false },
    :to_kibibytes => { kind: :method, name: "toKibibytes", is_optional: false },
    :to_mebibytes => { kind: :method, name: "toMebibytes", is_optional: false },
    :to_pebibytes => { kind: :method, name: "toPebibytes", is_optional: false },
    :to_tebibytes => { kind: :method, name: "toTebibytes", is_optional: false },
  }
end

.kibibytes(amount) ⇒ AWSCDK::Size

Create a Storage representing an amount kibibytes.

1 KiB = 1024 bytes

Parameters:

  • amount (Numeric)

    the amount of kibibytes to be represented.

Returns:

  • (AWSCDK::Size)

    a new Size instance



55
56
57
58
# File 'size.rb', line 55

def self.kibibytes(amount)
  Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Size", "kibibytes", [amount])
end

.mebibytes(amount) ⇒ AWSCDK::Size

Create a Storage representing an amount mebibytes.

1 MiB = 1024 KiB

Parameters:

  • amount (Numeric)

    the amount of mebibytes to be represented.

Returns:

  • (AWSCDK::Size)

    a new Size instance



66
67
68
69
# File 'size.rb', line 66

def self.mebibytes(amount)
  Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Size", "mebibytes", [amount])
end

.pebibytes(amount) ⇒ AWSCDK::Size

Create a Storage representing an amount pebibytes.

1 PiB = 1024 TiB

Parameters:

  • amount (Numeric)

    the amount of pebibytes to be represented.

Returns:

  • (AWSCDK::Size)

    a new Size instance



77
78
79
80
# File 'size.rb', line 77

def self.pebibytes(amount)
  Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Size", "pebibytes", [amount])
end

.tebibytes(amount) ⇒ AWSCDK::Size

Create a Storage representing an amount tebibytes.

1 TiB = 1024 GiB

Parameters:

  • amount (Numeric)

    the amount of tebibytes to be represented.

Returns:

  • (AWSCDK::Size)

    a new Size instance



88
89
90
91
# File 'size.rb', line 88

def self.tebibytes(amount)
  Jsii::Type.check_type(amount, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "amount")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Size", "tebibytes", [amount])
end

Instance Method Details

#is_unresolvedBoolean

Checks if size is a token or a resolvable object.

Returns:

  • (Boolean)


96
97
98
# File 'size.rb', line 96

def is_unresolved()
  jsii_call_method("isUnresolved", [])
end

#to_bytes(opts = nil) ⇒ Numeric

Return this storage as a total number of bytes.

Parameters:

Returns:

  • (Numeric)

    the quantity expressed in bytes



104
105
106
107
108
# File 'size.rb', line 104

def to_bytes(opts = nil)
  opts = opts.is_a?(Hash) ? ::AWSCDK::SizeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts
  Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil?
  jsii_call_method("toBytes", [opts])
end

#to_gibibytes(opts = nil) ⇒ Numeric

Return this storage as a total number of gibibytes.

Parameters:

Returns:

  • (Numeric)

    the quantity of bytes expressed in gibibytes



114
115
116
117
118
# File 'size.rb', line 114

def to_gibibytes(opts = nil)
  opts = opts.is_a?(Hash) ? ::AWSCDK::SizeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts
  Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil?
  jsii_call_method("toGibibytes", [opts])
end

#to_kibibytes(opts = nil) ⇒ Numeric

Return this storage as a total number of kibibytes.

Parameters:

Returns:

  • (Numeric)

    the quantity of bytes expressed in kibibytes



124
125
126
127
128
# File 'size.rb', line 124

def to_kibibytes(opts = nil)
  opts = opts.is_a?(Hash) ? ::AWSCDK::SizeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts
  Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil?
  jsii_call_method("toKibibytes", [opts])
end

#to_mebibytes(opts = nil) ⇒ Numeric

Return this storage as a total number of mebibytes.

Parameters:

Returns:

  • (Numeric)

    the quantity of bytes expressed in mebibytes



134
135
136
137
138
# File 'size.rb', line 134

def to_mebibytes(opts = nil)
  opts = opts.is_a?(Hash) ? ::AWSCDK::SizeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts
  Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil?
  jsii_call_method("toMebibytes", [opts])
end

#to_pebibytes(opts = nil) ⇒ Numeric

Return this storage as a total number of pebibytes.

Parameters:

Returns:

  • (Numeric)

    the quantity of bytes expressed in pebibytes



144
145
146
147
148
# File 'size.rb', line 144

def to_pebibytes(opts = nil)
  opts = opts.is_a?(Hash) ? ::AWSCDK::SizeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts
  Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil?
  jsii_call_method("toPebibytes", [opts])
end

#to_tebibytes(opts = nil) ⇒ Numeric

Return this storage as a total number of tebibytes.

Parameters:

Returns:

  • (Numeric)

    the quantity of bytes expressed in tebibytes



154
155
156
157
158
# File 'size.rb', line 154

def to_tebibytes(opts = nil)
  opts = opts.is_a?(Hash) ? ::AWSCDK::SizeConversionOptions.new(**opts.transform_keys(&:to_sym)) : opts
  Jsii::Type.check_type(opts, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplQ29udmVyc2lvbk9wdGlvbnMifQ==")), "opts") unless opts.nil?
  jsii_call_method("toTebibytes", [opts])
end