Class: DdbRuby::FifthEdition::SpellsClass
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::SpellsClass
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4305 def self.from_dynamic!(d) d = Types::Hash[d] new( override_save_dc: d.fetch("overrideSaveDc"), limited_use: d.fetch("limitedUse") ? ClassLimitedUse.from_dynamic!(d.fetch("limitedUse")) : nil, id: d.fetch("id"), entity_type_id: d.fetch("entityTypeId"), definition: d.fetch("definition") ? SpellDefinition.from_dynamic!(d.fetch("definition")) : nil, definition_id: d.fetch("definitionId"), prepared: d.fetch("prepared"), counts_as_known_spell: d.fetch("countsAsKnownSpell"), uses_spell_slot: d.fetch("usesSpellSlot"), cast_at_level: d.fetch("castAtLevel"), always_prepared: d.fetch("alwaysPrepared"), restriction: d.fetch("restriction"), spell_casting_ability_id: d.fetch("spellCastingAbilityId"), display_as_attack: d.fetch("displayAsAttack"), additional_description: d.fetch("additionalDescription"), cast_only_as_ritual: d.fetch("castOnlyAsRitual"), ritual_casting_type: d.fetch("ritualCastingType"), range: d.fetch("range") ? DefinitionRange.from_dynamic!(d.fetch("range")) : nil, activation: d.fetch("activation") ? Activation.from_dynamic!(d.fetch("activation")) : nil, base_level_at_will: d.fetch("baseLevelAtWill"), at_will_limited_use_level: d.fetch("atWillLimitedUseLevel"), is_signature_spell: d.fetch("isSignatureSpell"), component_id: d.fetch("componentId"), component_type_id: d.fetch("componentTypeId"), spell_list_id: d.fetch("spellListId"), ) end |
.from_json!(json) ⇒ Object
4336 4337 4338 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4336 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4340 def to_dynamic { "overrideSaveDc" => override_save_dc, "limitedUse" => limited_use&.to_dynamic, "id" => id, "entityTypeId" => entity_type_id, "definition" => definition&.to_dynamic, "definitionId" => definition_id, "prepared" => prepared, "countsAsKnownSpell" => counts_as_known_spell, "usesSpellSlot" => uses_spell_slot, "castAtLevel" => cast_at_level, "alwaysPrepared" => always_prepared, "restriction" => restriction, "spellCastingAbilityId" => spell_casting_ability_id, "displayAsAttack" => display_as_attack, "additionalDescription" => additional_description, "castOnlyAsRitual" => cast_only_as_ritual, "ritualCastingType" => ritual_casting_type, "range" => range&.to_dynamic, "activation" => activation&.to_dynamic, "baseLevelAtWill" => base_level_at_will, "atWillLimitedUseLevel" => at_will_limited_use_level, "isSignatureSpell" => is_signature_spell, "componentId" => component_id, "componentTypeId" => component_type_id, "spellListId" => spell_list_id, } end |
#to_json(options = nil) ⇒ Object
4370 4371 4372 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4370 def to_json( = nil) JSON.generate(to_dynamic, ) end |