[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Creating classes with from YAML?

Richard Kilmer

9/23/2003 7:14:00 PM

C1 = YAML.load("--- !ruby/object:Class {}")


The easiest way to figure out how to represent something in Ruby in
YAML is just to call #to_yaml on your object:

require 'yaml'
C1 = Class.new
puts C1.to_yaml #=> --- !ruby/object:Class {}

-rich

On Tuesday, September 23, 2003, at 03:01 PM, David Garamond wrote:

> Remembering that all classes are instances of the Class class, is this
> possible? I want to create some class named, say C1, which is empty
> (or perhaps with one or two class instance vars) by loading a YAML
> document. I can't seem to create instances of Class class in YAML,
> while I can easily do this in irb:
>
> $ irb
> irb(main):001:0> C1=Class.new
> => C1
> irb(main):002:0> C1.new
> => #<C1:0x40174a1c>
>
> --
> dave
>
>
>
>