Created
August 31, 2013 15:30
-
-
Save tdantas/6398955 to your computer and use it in GitHub Desktop.
YAML Ruby Custom Data Type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
%w(yaml ap ostruct).each { |dep| require dep } | |
class Plans | |
attr_accessor :name, :price, :recurrence | |
def initialize(name, price, recurrence) | |
@name = name | |
@price = price | |
@recurrence = recurrence | |
end | |
end | |
obj = YAML::load(DATA) | |
p obj | |
__END__ | |
Plans: | |
- !ruby/object:Plans | |
name: 'XStart' | |
price: 120 | |
recurrence: monthly | |
- !ruby/object:Plans { name: 'Unlimited', price: '399', recurrence: 'monthly' } | |
- !ruby/object:Plans | |
name: Intermediate | |
price: 230 | |
recurrence: monthly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment