Class: DdbRuby::FifthEdition::CreatureRule
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::CreatureRule
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1881 def self.from_dynamic!(d) d = Types::Hash[d] new( creature_group_id: d.fetch("creatureGroupId"), monster_type_id: d.fetch("monsterTypeId"), max_challenge_rating_id: d.fetch("maxChallengeRatingId"), level_divisor: d.fetch("levelDivisor"), monster_ids: d.fetch("monsterIds"), movement_ids: d.fetch("movementIds"), size_ids: d.fetch("sizeIds"), ) end |
.from_json!(json) ⇒ Object
1894 1895 1896 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1894 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1898 def to_dynamic { "creatureGroupId" => creature_group_id, "monsterTypeId" => monster_type_id, "maxChallengeRatingId" => , "levelDivisor" => level_divisor, "monsterIds" => monster_ids, "movementIds" => movement_ids, "sizeIds" => size_ids, } end |
#to_json(options = nil) ⇒ Object
1910 1911 1912 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1910 def to_json( = nil) JSON.generate(to_dynamic, ) end |