Class: RichterCatalogue::Artist

Inherits:
Object
  • Object
show all
Defined in:
lib/richter_catalogue/artist.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes_hash) ⇒ Artist

Returns a new instance of Artist.



5
6
7
8
9
# File 'lib/richter_catalogue/artist.rb', line 5

def initialize(attributes_hash)
  self.add_artist_attributes(attributes_hash)
  @paintings = []
  @@all << self
end

Instance Attribute Details

#ageObject

Returns the value of attribute age.



2
3
4
# File 'lib/richter_catalogue/artist.rb', line 2

def age
  @age
end

#artist_urlObject

Returns the value of attribute artist_url.



2
3
4
# File 'lib/richter_catalogue/artist.rb', line 2

def artist_url
  @artist_url
end

#educationObject

Returns the value of attribute education.



2
3
4
# File 'lib/richter_catalogue/artist.rb', line 2

def education
  @education
end

#movementObject

Returns the value of attribute movement.



2
3
4
# File 'lib/richter_catalogue/artist.rb', line 2

def movement
  @movement
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/richter_catalogue/artist.rb', line 2

def name
  @name
end

#nationalityObject

Returns the value of attribute nationality.



2
3
4
# File 'lib/richter_catalogue/artist.rb', line 2

def nationality
  @nationality
end

#paintingsObject

Returns the value of attribute paintings.



2
3
4
# File 'lib/richter_catalogue/artist.rb', line 2

def paintings
  @paintings
end

#subjectsObject

Returns the value of attribute subjects.



2
3
4
# File 'lib/richter_catalogue/artist.rb', line 2

def subjects
  @subjects
end

Class Method Details

.allObject



11
12
13
# File 'lib/richter_catalogue/artist.rb', line 11

def self.all
  @@all
end

.create_from_profile(attributes_hash) ⇒ Object



15
16
17
# File 'lib/richter_catalogue/artist.rb', line 15

def self.create_from_profile(attributes_hash)
  RichterCatalogue::Artist.new(attributes_hash)
end

.find_by_name(name) ⇒ Object



33
34
35
# File 'lib/richter_catalogue/artist.rb', line 33

def self.find_by_name(name)
  self.all.detect{|artist| artist.name == name}
end

Instance Method Details

#add_artist_attributes(attributes_hash) ⇒ Object



19
20
21
22
# File 'lib/richter_catalogue/artist.rb', line 19

def add_artist_attributes(attributes_hash)
  attributes_hash.each {|key, value| self.send("#{key}=", value)}
  self
end

#add_painting(painting) ⇒ Object



24
25
26
27
# File 'lib/richter_catalogue/artist.rb', line 24

def add_painting(painting)
  painting.artist = self unless painting.artist == self
  @paintings << painting unless @paintings.include?(painting)
end