Class: DdbRuby::FifthEdition::LevelScale
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::LevelScale
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1989 def self.from_dynamic!(d) d = Types::Hash[d] new( id: d.fetch("id"), level: d.fetch("level"), description: d.fetch("description"), dice: d.fetch("dice") ? HitPointDice.from_dynamic!(d.fetch("dice")) : nil, fixed_value: d.fetch("fixedValue"), ) end |
.from_json!(json) ⇒ Object
2000 2001 2002 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2000 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2004 2005 2006 2007 2008 2009 2010 2011 2012 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2004 def to_dynamic { "id" => id, "level" => level, "description" => description, "dice" => dice&.to_dynamic, "fixedValue" => fixed_value, } end |
#to_json(options = nil) ⇒ Object
2014 2015 2016 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2014 def to_json( = nil) JSON.generate(to_dynamic, ) end |