Class: DdbRuby::FifthEdition::SpellRules
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::SpellRules
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2325 def self.from_dynamic!(d) d = Types::Hash[d] new( multi_class_spell_slot_divisor: d.fetch("multiClassSpellSlotDivisor"), is_ritual_spell_caster: d.fetch("isRitualSpellCaster"), level_cantrips_known_maxes: d.fetch("levelCantripsKnownMaxes"), level_spell_known_maxes: d.fetch("levelSpellKnownMaxes"), level_spell_slots: d.fetch("levelSpellSlots"), multi_class_spell_slot_rounding: d.fetch("multiClassSpellSlotRounding"), ) end |
.from_json!(json) ⇒ Object
2337 2338 2339 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2337 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2341 def to_dynamic { "multiClassSpellSlotDivisor" => multi_class_spell_slot_divisor, "isRitualSpellCaster" => is_ritual_spell_caster, "levelCantripsKnownMaxes" => level_cantrips_known_maxes, "levelSpellKnownMaxes" => level_spell_known_maxes, "levelSpellSlots" => level_spell_slots, "multiClassSpellSlotRounding" => multi_class_spell_slot_rounding, } end |
#to_json(options = nil) ⇒ Object
2352 2353 2354 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2352 def to_json( = nil) JSON.generate(to_dynamic, ) end |