Class: MockServer::Delay
- Inherits:
-
Object
- Object
- MockServer::Delay
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#distribution ⇒ Object
Returns the value of attribute distribution.
-
#time_unit ⇒ Object
Returns the value of attribute time_unit.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(time_unit: 'MILLISECONDS', value: 0, distribution: nil) ⇒ Delay
constructor
A new instance of Delay.
- #to_h ⇒ Object
Constructor Details
#initialize(time_unit: 'MILLISECONDS', value: 0, distribution: nil) ⇒ Delay
Returns a new instance of Delay.
215 216 217 218 219 |
# File 'lib/mockserver/models.rb', line 215 def initialize(time_unit: 'MILLISECONDS', value: 0, distribution: nil) @time_unit = time_unit @value = value @distribution = distribution end |
Instance Attribute Details
#distribution ⇒ Object
Returns the value of attribute distribution.
213 214 215 |
# File 'lib/mockserver/models.rb', line 213 def distribution @distribution end |
#time_unit ⇒ Object
Returns the value of attribute time_unit.
213 214 215 |
# File 'lib/mockserver/models.rb', line 213 def time_unit @time_unit end |
#value ⇒ Object
Returns the value of attribute value.
213 214 215 |
# File 'lib/mockserver/models.rb', line 213 def value @value end |
Class Method Details
.from_hash(data) ⇒ Object
229 230 231 232 233 234 235 236 237 238 |
# File 'lib/mockserver/models.rb', line 229 def self.from_hash(data) return nil if data.nil? dist_data = data['distribution'] new( time_unit: data.fetch('timeUnit', 'MILLISECONDS'), value: data.fetch('value', 0), distribution: dist_data ? DelayDistribution.from_hash(dist_data) : nil ) end |
Instance Method Details
#to_h ⇒ Object
221 222 223 224 225 226 227 |
# File 'lib/mockserver/models.rb', line 221 def to_h MockServer.strip_none({ 'timeUnit' => @time_unit, 'value' => @value, 'distribution' => @distribution&.to_h }) end |