Guest User

Untitled

a guest
Jun 19th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. module Gosu
  2. class Color
  3. # Setting up for YAML
  4. YAML_DOMAIN = 'libgosu.org,2010'
  5. YAML_TYPE = 'color'
  6.  
  7. YAML::add_domain_type(YAML_DOMAIN, YAML_TYPE) do |type, value|
  8. p type, value
  9. Gosu::Color.new(*value[:rgba])
  10. end
  11.  
  12. def to_yaml
  13. "--- #{to_yaml_type} \nrgba: [#{red}, #{green}, #{blue}, #{alpha}]\n"
  14. end
  15.  
  16. def to_yaml_type
  17. "!#{YAML_DOMAIN}/#{YAML_TYPE}"
  18. end
  19. end
  20. end
  21.  
  22. Gosu::Color.new(1, 2, 3, 4).to_yaml
  23. YAML.load(Gosu::Color.new(1, 2, 3, 4).to_yaml)
Add Comment
Please, Sign In to add comment