class BestReads::List
Attributes
books[RW]
name[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/best_reads/list.rb, line 27 def self.all @@all end
create_and_display_from_collection(list_hash)
click to toggle source
# File lib/best_reads/list.rb, line 5 def self.create_and_display_from_collection (list_hash) list_hash.each_with_index do |list, index| new_list = self.new() list.each {|key, value| new_list.send(("#{key}="),value.strip)} new_list.save new_list.display_by_index(index) end self.all end
find_by_index(index)
click to toggle source
# File lib/best_reads/list.rb, line 23 def self.find_by_index(index) self.all[index.to_i-1] end
Public Instance Methods
display_by_index(index)
click to toggle source
# File lib/best_reads/list.rb, line 15 def display_by_index(index) puts "#{index+1}. #{self.name}" end
save()
click to toggle source
# File lib/best_reads/list.rb, line 19 def save self.class.all<<self end