Class: RichterCatalogue::Painting
- Inherits:
-
Object
- Object
- RichterCatalogue::Painting
- Defined in:
- lib/richter_catalogue/painting.rb
Constant Summary collapse
- @@all =
[]
- @@names_all =
[]
Instance Attribute Summary collapse
-
#artist ⇒ Object
Returns the value of attribute artist.
-
#medium ⇒ Object
Returns the value of attribute medium.
-
#name ⇒ Object
Returns the value of attribute name.
-
#painting_url ⇒ Object
Returns the value of attribute painting_url.
-
#price ⇒ Object
Returns the value of attribute price.
-
#size ⇒ Object
Returns the value of attribute size.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#year ⇒ Object
Returns the value of attribute year.
Class Method Summary collapse
- .all ⇒ Object
- .create_from_subject(paintings_array, subject = nil) ⇒ Object
- .display(painting) ⇒ Object
- .display_name(painting) ⇒ Object
- .find_by_name(name) ⇒ Object
- .names ⇒ Object
Instance Method Summary collapse
- #add_attributes(attributes_hash) ⇒ Object
-
#initialize(attributes_hash) ⇒ Painting
constructor
A new instance of Painting.
Constructor Details
#initialize(attributes_hash) ⇒ Painting
Returns a new instance of Painting.
8 9 10 11 |
# File 'lib/richter_catalogue/painting.rb', line 8 def initialize(attributes_hash) attributes_hash.each {|key, value| self.send("#{key}=", value)} @@all << self end |
Instance Attribute Details
#artist ⇒ Object
Returns the value of attribute artist.
3 4 5 |
# File 'lib/richter_catalogue/painting.rb', line 3 def artist @artist end |
#medium ⇒ Object
Returns the value of attribute medium.
2 3 4 |
# File 'lib/richter_catalogue/painting.rb', line 2 def medium @medium end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/richter_catalogue/painting.rb', line 2 def name @name end |
#painting_url ⇒ Object
Returns the value of attribute painting_url.
2 3 4 |
# File 'lib/richter_catalogue/painting.rb', line 2 def painting_url @painting_url end |
#price ⇒ Object
Returns the value of attribute price.
2 3 4 |
# File 'lib/richter_catalogue/painting.rb', line 2 def price @price end |
#size ⇒ Object
Returns the value of attribute size.
2 3 4 |
# File 'lib/richter_catalogue/painting.rb', line 2 def size @size end |
#subject ⇒ Object
Returns the value of attribute subject.
3 4 5 |
# File 'lib/richter_catalogue/painting.rb', line 3 def subject @subject end |
#year ⇒ Object
Returns the value of attribute year.
2 3 4 |
# File 'lib/richter_catalogue/painting.rb', line 2 def year @year end |
Class Method Details
.all ⇒ Object
28 29 30 |
# File 'lib/richter_catalogue/painting.rb', line 28 def self.all @@all end |
.create_from_subject(paintings_array, subject = nil) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/richter_catalogue/painting.rb', line 14 def self.create_from_subject(paintings_array, subject = nil) paintings_array.each do |attributes_hash| new_painting = RichterCatalogue::Painting.new(attributes_hash) new_painting.subject = subject end end |
.display(painting) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/richter_catalogue/painting.rb', line 51 def self.display(painting) puts " name: #{painting.name}" puts " year: #{painting.year.name}" puts " size: #{painting.size}" puts " medium: #{painting.medium}" if !(painting.price == "") puts " price: #{painting.price}" end puts "------------------------" end |
.display_name(painting) ⇒ Object
47 48 49 |
# File 'lib/richter_catalogue/painting.rb', line 47 def self.display_name(painting) puts "- #{painting.name}" end |
.find_by_name(name) ⇒ Object
68 69 70 |
# File 'lib/richter_catalogue/painting.rb', line 68 def self.find_by_name(name) self.all.select{|painting| painting.name == name} end |
.names ⇒ Object
64 65 66 |
# File 'lib/richter_catalogue/painting.rb', line 64 def self.names RichterCatalogue::Painting.all.collect {|painting| painting.name}.uniq end |
Instance Method Details
#add_attributes(attributes_hash) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/richter_catalogue/painting.rb', line 21 def add_attributes(attributes_hash) attributes_hash.each do |key, value| self.send("#{key}=", value) end self end |