Class: DdbRuby::FifthEdition::RaceElement
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::RaceElement
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4111 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: SpellDefinition.from_dynamic!(d.fetch("definition")), 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: DefinitionRange.from_dynamic!(d.fetch("range")), activation: Activation.from_dynamic!(d.fetch("activation")), 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
4142 4143 4144 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4142 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4146 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
4176 4177 4178 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4176 def to_json( = nil) JSON.generate(to_dynamic, ) end |