Class: DdbRuby::FifthEdition::DisplayConfiguration

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/ddb_ruby/fifth_edition/structs.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



1902
1903
1904
1905
1906
1907
1908
1909
1910
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1902

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    racialtrait:  d.fetch("RACIALTRAIT"),
    language:     d.fetch("LANGUAGE"),
    abilityscore: d.fetch("ABILITYSCORE"),
    classfeature: d.fetch("CLASSFEATURE"),
  )
end

.from_json!(json) ⇒ Object



1912
1913
1914
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1912

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



1916
1917
1918
1919
1920
1921
1922
1923
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1916

def to_dynamic
  {
    "RACIALTRAIT"  => racialtrait,
    "LANGUAGE"     => language,
    "ABILITYSCORE" => abilityscore,
    "CLASSFEATURE" => classfeature,
  }
end

#to_json(options = nil) ⇒ Object



1925
1926
1927
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1925

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end