# Can't read Yaml for domain type

**URL:** <https://www.ruby-forum.com/t/cant-read-yaml-for-domain-type/166551>\
**Category:** Ruby\
**Created:** [April 27, 2009, 9:34am UTC](https://www.ruby-forum.com/t/cant-read-yaml-for-domain-type/166551 "2009-04-27T09:34:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gganesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e95f7d/32.png) [@gganesh](https://www.ruby-forum.com/u/gganesh)\
**Post date:** [April 27, 2009, 9:34am UTC](https://www.ruby-forum.com/t/cant-read-yaml-for-domain-type/166551/1 "2009-04-27T09:34:17Z")

</div>

I have one yaml file “content.yml” which has content,

* * *

key: !DBClass  
debug: Y  
Directory : /var/tmp  
name: John  
phone: 487394

As, I am trying to load the file via,

obj= YAML.load(File.open(“content.yml”))

But i dont know that how to acess the individual variable from this  
content.  
for eg, How do i will get the Directory or name or phone ?

---

<div class="post-metadata">

**Author:** ![gganesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e95f7d/32.png) [@gganesh](https://www.ruby-forum.com/u/gganesh)\
**Post date:** [April 27, 2009, 7:06pm UTC](https://www.ruby-forum.com/t/cant-read-yaml-for-domain-type/166551/2 "2009-04-27T19:06:39Z")

</div>

Ganesh Girase wrote:

> As, I am trying to load the file via,
> 
> obj= YAML.load(File.open(“content.yml”))
> 
> But i dont know that how to acess the individual variable from this  
> content.  
> for eg, How do i will get the Directory or name or phone ?

There should be some code that defines the DBClass type for YAML (maybe  
you can check with whoever wrote that data?). In the meantime, you can  
do this:

require ‘yaml’

h = YAML.load(DATA)[“key”].instance\_variable\_get(:@value)

p h # {“name”=\>“John”, “Directory”=\>"/var/tmp", “phone”=\>487394,  
“debug”=\>“Y”}

p h[“Directory”] # “/var/tmp”

**END**

* * *

key: !DBClass  
debug: Y  
Directory : /var/tmp  
name: John  
phone: 487394
