From: RubyQuestions@... (RubyQuestions) Date: 2003-12-03T11:17:06+09:00 Subject: YAML Question: Using YAML::YamlNode#transform Method to get float values? I'm trying to use the transform method in YAML to grab the values from my classes. Everything works correctly, except when I try to get the price data (Floats) from my class. I'm trying to understand if I should be doing something different. Thanks. Here is my sample script and IRB session: require 'yaml' class Video attr_accessor :price, :title, :director, :year def initialize(p, t, d, y) @price = p @title = t @director = d @year = y end end myVideoCollection = [ Video.new(22.45, "Moonshine Hustler", "Moose McDaniel", 1928), Video.new(19.72, "Crazy Cool Camels", "Rob Crowfeet", 1985) ] videos = {"Videos" => myVideoCollection} ##########IRB############# irb(main):035:0> puts videos.to_yaml --- Videos: - !ruby/object:Video director: Moose McDaniel price: 22.45 title: Moonshine Hustler year: 1928 - !ruby/object:Video director: Rob Crowfeet price: 19.72 title: Crazy Cool Camels year: 1985 ########################## videoListYaml = YAML::parse(videos.to_yaml) Summary ######################### irb(main):065:0> p videoListYaml.select("Videos//title").transform ["Moonshine Hustler", "Crazy Cool Camels"] ## WORKS... irb(main):066:0> p videoListYaml.select("Videos//director").transform ["Moose McDaniel", "Rob Crowfeet"] ## WORKS... irb(main):067:0> p videoListYaml.select("Videos//year").transform [1928, 1985] ## WORKS... irb(main):068:0> p videoListYaml.select("Videos//price").transform [#, #] ## Why isn't this parsing out the two Float values for price? #########################