Class: DdbRuby::FifthEdition::Item
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::Item
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4208 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
4239 4240 4241 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4239 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4243 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
4273 4274 4275 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4273 def to_json( = nil) JSON.generate(to_dynamic, ) end |