Class: RichterCatalogue::Subject
- Inherits:
-
Object
- Object
- RichterCatalogue::Subject
- Defined in:
- lib/richter_catalogue/subject.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#artists ⇒ Object
Returns the value of attribute artists.
-
#name ⇒ Object
Returns the value of attribute name.
-
#paintings ⇒ Object
Returns the value of attribute paintings.
-
#subject_url ⇒ Object
Returns the value of attribute subject_url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_painting(painting) ⇒ Object
-
#initialize ⇒ Subject
constructor
A new instance of Subject.
Constructor Details
#initialize ⇒ Subject
Returns a new instance of Subject.
5 6 7 8 |
# File 'lib/richter_catalogue/subject.rb', line 5 def initialize @@all << self @paintings = [] end |
Instance Attribute Details
#artists ⇒ Object
Returns the value of attribute artists.
2 3 4 |
# File 'lib/richter_catalogue/subject.rb', line 2 def artists @artists end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/richter_catalogue/subject.rb', line 2 def name @name end |
#paintings ⇒ Object
Returns the value of attribute paintings.
2 3 4 |
# File 'lib/richter_catalogue/subject.rb', line 2 def paintings @paintings end |
#subject_url ⇒ Object
Returns the value of attribute subject_url.
2 3 4 |
# File 'lib/richter_catalogue/subject.rb', line 2 def subject_url @subject_url end |
Class Method Details
.all ⇒ Object
10 11 12 |
# File 'lib/richter_catalogue/subject.rb', line 10 def self.all @@all end |
.create_from_subjects(subjects_array) ⇒ Object
14 15 16 17 18 19 |
# 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) ⇒ Object
30 31 32 |
# File 'lib/richter_catalogue/subject.rb', line 30 def self.find_by_name(name) self.all.detect{|subject| subject.name == name} end |
Instance Method Details
#add_painting(painting) ⇒ Object
25 26 27 28 |
# 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 |