Class: DdbRuby::FifthEdition::HitPointDice
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::HitPointDice
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 83 def self.from_dynamic!(d) d = Types::Hash[d] new( dice_count: d.fetch("diceCount"), dice_value: d.fetch("diceValue"), dice_multiplier: d.fetch("diceMultiplier"), fixed_value: d.fetch("fixedValue"), dice_string: d.fetch("diceString"), ) end |
.from_json!(json) ⇒ Object
94 95 96 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 94 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 98 def to_dynamic { "diceCount" => dice_count, "diceValue" => dice_value, "diceMultiplier" => dice_multiplier, "fixedValue" => fixed_value, "diceString" => dice_string, } end |
#to_json(options = nil) ⇒ Object
108 109 110 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 108 def to_json( = nil) JSON.generate(to_dynamic, ) end |