Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. # File: ruby-serialization-3.rb
  2. #
  3. require 'json'
  4.  
  5. class Customer
  6. attr_accessor :name, :email
  7.  
  8. def initialize(name, email)
  9. @name = name
  10. @email = email
  11. end
  12.  
  13. def to_json
  14. {name: name, email: email}.to_json
  15. end
  16. end
  17.  
  18. customer = Customer.new('John Smith', 'john_smith@mailinator.com')
  19. File.write('customers-db.json', customer.to_json)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement