Class: DdbRuby::FifthEdition::Race
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::Race
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4007 def self.from_dynamic!(d) d = Types::Hash[d] new( is_sub_race: d.fetch("isSubRace"), base_race_name: d.fetch("baseRaceName"), entity_race_id: d.fetch("entityRaceId"), entity_race_type_id: d.fetch("entityRaceTypeId"), definition_key: d.fetch("definitionKey"), full_name: d.fetch("fullName"), base_race_id: d.fetch("baseRaceId"), base_race_type_id: d.fetch("baseRaceTypeId"), description: d.fetch("description"), avatar_url: d.fetch("avatarUrl"), large_avatar_url: d.fetch("largeAvatarUrl"), portrait_avatar_url: d.fetch("portraitAvatarUrl"), more_details_url: d.fetch("moreDetailsUrl"), is_homebrew: d.fetch("isHomebrew"), is_legacy: d.fetch("isLegacy"), group_ids: d.fetch("groupIds"), race_type: d.fetch("type"), supports_subrace: d.fetch("supportsSubrace"), sub_race_short_name: d.fetch("subRaceShortName"), base_name: d.fetch("baseName"), racial_traits: d.fetch("racialTraits").map { |x| RacialTrait.from_dynamic!(x) }, weight_speeds: WeightSpeeds.from_dynamic!(d.fetch("weightSpeeds")), feat_ids: d.fetch("featIds"), size: d.fetch("size"), size_id: d.fetch("sizeId"), sources: d.fetch("sources").map { |x| Source.from_dynamic!(x) }, ) end |
.from_json!(json) ⇒ Object
4039 4040 4041 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4039 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4043 def to_dynamic { "isSubRace" => is_sub_race, "baseRaceName" => base_race_name, "entityRaceId" => entity_race_id, "entityRaceTypeId" => entity_race_type_id, "definitionKey" => definition_key, "fullName" => full_name, "baseRaceId" => base_race_id, "baseRaceTypeId" => base_race_type_id, "description" => description, "avatarUrl" => avatar_url, "largeAvatarUrl" => large_avatar_url, "portraitAvatarUrl" => portrait_avatar_url, "moreDetailsUrl" => more_details_url, "isHomebrew" => is_homebrew, "isLegacy" => is_legacy, "groupIds" => group_ids, "type" => race_type, "supportsSubrace" => supports_subrace, "subRaceShortName" => sub_race_short_name, "baseName" => base_name, "racialTraits" => racial_traits.map { |x| x.to_dynamic }, "weightSpeeds" => weight_speeds.to_dynamic, "featIds" => feat_ids, "size" => size, "sizeId" => size_id, "sources" => sources.map { |x| x.to_dynamic }, } end |
#to_json(options = nil) ⇒ Object
4074 4075 4076 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4074 def to_json( = nil) JSON.generate(to_dynamic, ) end |