Class: DdbRuby::FifthEdition::Creature
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::Creature
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2888 def self.from_dynamic!(d) d = Types::Hash[d] new( id: d.fetch("id"), entity_type_id: d.fetch("entityTypeId"), creature_name: d.fetch("name"), description: d.fetch("description"), is_active: d.fetch("isActive"), removed_hit_points: d.fetch("removedHitPoints"), temporary_hit_points: d.fetch("temporaryHitPoints"), group_id: d.fetch("groupId"), definition: CreatureDefinition.from_dynamic!(d.fetch("definition")), ) end |
.from_json!(json) ⇒ Object
2903 2904 2905 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2903 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2907 def to_dynamic { "id" => id, "entityTypeId" => entity_type_id, "name" => creature_name, "description" => description, "isActive" => is_active, "removedHitPoints" => removed_hit_points, "temporaryHitPoints" => temporary_hit_points, "groupId" => group_id, "definition" => definition.to_dynamic, } end |
#to_json(options = nil) ⇒ Object
2921 2922 2923 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2921 def to_json( = nil) JSON.generate(to_dynamic, ) end |