Class: DdbRuby::FifthEdition::Options
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::Options
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
902 903 904 905 906 907 908 909 910 911 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 902 def self.from_dynamic!(d) d = Types::Hash[d] new( race: d.fetch("race").map { |x| OptionsClass.from_dynamic!(x) }, options_class: d.fetch("class").map { |x| OptionsClass.from_dynamic!(x) }, background: d.fetch("background"), item: d.fetch("item"), feat: d.fetch("feat").map { |x| OptionsClass.from_dynamic!(x) }, ) end |
.from_json!(json) ⇒ Object
913 914 915 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 913 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
917 918 919 920 921 922 923 924 925 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 917 def to_dynamic { "race" => race.map { |x| x.to_dynamic }, "class" => .map { |x| x.to_dynamic }, "background" => background, "item" => item, "feat" => feat.map { |x| x.to_dynamic }, } end |
#to_json(options = nil) ⇒ Object
927 928 929 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 927 def to_json( = nil) JSON.generate(to_dynamic, ) end |