def self.grab article = self.article_names links = self.article_links body = self.article_body articles = {} articles[:title] = article articles[:url] = links articles[:body] = body art = Ello::Hello.new art(articles) end When I run this with
class Ello::Hello attr_accessor :url, :article, :body, @@all = [] def initialize(hash) @article = hash["title"] @body = hash["body"] @url = hash["url"] @@all << self end def self.all @@all end end I get wrong number of arguments error? I know that usually when it says wrong number it means that it's not exactly reading the argument that I put in. But I feel like I did put in an argument but I'm unsure of why it's not being read.
Ello::Hello.new(articles)instead, the parameters must be passed right when you initialize a new object.self.allis defined as@all ||= [ ]and then you can doself.class.all << selfin the instance if you need this. Remember retaining every object can prevent the garbage collector from doing its job.