# The problem of to\_yaml

**URL:** <https://www.ruby-forum.com/t/the-problem-of-to-yaml/186384>\
**Category:** Ruby\
**Created:** [April 6, 2010, 5:03am UTC](https://www.ruby-forum.com/t/the-problem-of-to-yaml/186384 "2010-04-06T05:03:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luofeiyu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9de0a6/32.png) [@luofeiyu](https://www.ruby-forum.com/u/luofeiyu)\
**Post date:** [April 6, 2010, 5:03am UTC](https://www.ruby-forum.com/t/the-problem-of-to-yaml/186384/1 "2010-04-06T05:03:36Z")

</div>

here is a program

# MIT LICENSE

# 

# Copyright (c) 2007 Soledad Penades [www.soledadpenades.com](http://www.soledadpenades.com)

# 

# Permission is hereby granted, free of charge, to any person obtaining

a copy

# of this software and associated documentation files (the “Software”),

to deal

# in the Software without restriction, including without limitation the

rights

# to use, copy, modify, merge, publish, distribute, sublicense, and/or

sell

# copies of the Software, and to permit persons to whom the Software is

# furnished to do so, subject to the following conditions:

# 

# The above copyright notice and this permission notice shall be

included in

# all copies or substantial portions of the Software.

# 

# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,

EXPRESS OR

# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

MERCHANTABILITY,

# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT

SHALL THE

# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,

ARISING FROM,

# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS

IN

# THE SOFTWARE.

require ‘rubygems’  
require ‘hpricot’  
require ‘open-uri’  
doc =  
Hpricot(open(“[EXIF Tags](http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html)”))  
#doc = open(“EXIF.html”) { |f| Hpricot(f) }

rows = []

(doc/“table.inner//tr”).each do |row|  
cells = []  
(row/“td”).each do |cell|

```
    if (cell/" span.s").length > 0
          values = (cell/"span.s").inner_html.split('<br

```

/\>‘).collect{ |str|  
pair = str.strip.split(’=').collect{|val| val.strip}  
Hash[pair[0], pair[1]]  
}

```
        if(values.length==1)
          cells << cell.inner_text
        else
          cells << values
        end

    elsif
        cells << cell.inner_text
    end
end
rows << cells

```

end

rows.shift

#p rows.to\_yaml

File.open(‘/home/pt/test/hexif.yaml’, ‘w’) { |f|  
f \<\< rows.to\_yaml  
}  
when i run ,  
pt@pt-laptop:~$ ruby /home/pt/test/row.rb  
/home/pt/test/row.rb:61:in `block in <main>': undefined method `to\_yaml’  
for #Array:0x9159ad0 (NoMethodError)  
from /home/pt/test/row.rb:60:in `open' from /home/pt/test/row.rb:60:in `’

what’s the matter?

---

<div class="post-metadata">

**Author:** ![luofeiyu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9de0a6/32.png) [@luofeiyu](https://www.ruby-forum.com/u/luofeiyu)\
**Post date:** [April 6, 2010, 5:16am UTC](https://www.ruby-forum.com/t/the-problem-of-to-yaml/186384/2 "2010-04-06T05:16:05Z")

</div>

Did you:

require ‘yaml’
