class RichterCatalogue::Subject

Attributes

artists[RW]
name[RW]
paintings[RW]
subject_url[RW]

Public Class Methods

all() click to toggle source
# File lib/richter_catalogue/subject.rb, line 10
def self.all
  @@all
end
create_from_subjects(subjects_array) click to toggle source
# File lib/richter_catalogue/subject.rb, line 14
def self.create_from_subjects(subjects_array)
  subjects_array.each do |subject_hash|
    new_subject = RichterCatalogue::Subject.new
    subject_hash.each {|key, value| new_subject.send("#{key}=", value)}
  end
end
find_by_name(name) click to toggle source
# File lib/richter_catalogue/subject.rb, line 30
def self.find_by_name(name)
  self.all.detect{|subject| subject.name == name}
end
new() click to toggle source
# File lib/richter_catalogue/subject.rb, line 5
def initialize
  @@all << self
  @paintings = []
end

Public Instance Methods

add_painting(painting) click to toggle source
# File lib/richter_catalogue/subject.rb, line 25
def add_painting(painting)
  painting.artist = self unless painting.artist == self
  @paintings << painting unless @paintings.include?(painting)
end