From: Daniel Sheppard Date: 2006-06-07T11:35:49+09:00 Subject: Re: Attributes not populated until called? > Ok, so I changed the code so the assignments are in > initialize(). Now I am > getting some broken behavior. First of all, most of the tags > are getting set > by the super class which is only supposed to happen if the > tag is 'comment': ... > @comment = super That line calls the initialize() method from your superclass and assigns the result of that method (coming from the last line "@tracknum = 'unknown'") to the @comment variable. What you probably want is: module TagDisplayer ATTRIBUTES = %w{title artist album genre year comment tracknum} attr_reader *ATTRIBUTES def to_a ATTRIBUTES.map {|x| send(x)} end def to_s ATTRIBUTES.map {|x| "#{x.capitalize}: #{send(x)}" }.join("\n") end end class MetaTags include TagDisplayer def initialize(filename) @filename = filename @title = @filename[0..-5] @artist = @title @album = 'unknown' @genre = 'unknown' @year = 'unknown' @comment = 'Starbellied using sneetchalizer' @tracknum = 'unknown' end end class OggMetaTags < MetaTags include TagDisplayer def initialize(filename) @filename = filename require 'ogginfo' @tags = OggInfo.new(@filename) @title = @tags.tag['title'] @artist = @tags.tag['artist'] @album = @tags.tag['album'] @genre = @tags.tag['genre'] @year = @tags.tag['date'] @comment = 'Starbellied using sneetchalizer' @tracknum = @tags.tag['tracknumber'] end end