Class: DdbRuby::FifthEdition::WeightSpeeds

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/ddb_ruby/fifth_edition/structs.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3949

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    normal:             Normal.from_dynamic!(d.fetch("normal")),
    encumbered:         d.fetch("encumbered"),
    heavily_encumbered: d.fetch("heavilyEncumbered"),
    push_drag_lift:     d.fetch("pushDragLift"),
    override:           d.fetch("override"),
  )
end

.from_json!(json) ⇒ Object



3960
3961
3962
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3960

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



3964
3965
3966
3967
3968
3969
3970
3971
3972
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3964

def to_dynamic
  {
    "normal"            => normal.to_dynamic,
    "encumbered"        => encumbered,
    "heavilyEncumbered" => heavily_encumbered,
    "pushDragLift"      => push_drag_lift,
    "override"          => override,
  }
end

#to_json(options = nil) ⇒ Object



3974
3975
3976
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3974

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end