https://github.com/turingschool-examples/museo
https://github.com/turingschool-examples/museo
be-1 practice-assessment ruby
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/turingschool-examples/museo
- Owner: turingschool-examples
- Created: 2018-09-16T23:08:44.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2023-03-08T19:04:15.000Z (over 3 years ago)
- Last Synced: 2025-06-25T08:42:37.737Z (about 1 year ago)
- Topics: be-1, practice-assessment, ruby
- Language: Ruby
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 7
- Forks: 224
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Museo
## Setup
* Fork this Repository
* Clone YOUR fork
* Compete the activity below
* Push your solution to your fork
* Submit a pull request from your repository to the turingschool-examples repository
* Make sure to put your name in your PR!
### Iteration 1
```markdown
There are **3** points possible in Iteration 1:
1. Artist Creation (must include all attributes)
2. Photograph Creation (must include all attributes)
3. Artist #age_at_death
```
Use TDD to create a `Photograph` and an `Artist` class that respond to the following interaction pattern.
For `age_at_death`, assume an artist was born and died on the same day.
```ruby
pry(main)> require './lib/photograph'
#=> true
pry(main)> require './lib/artist'
#=> true
pry(main)> attributes = {
id: "1",
name: "Rue Mouffetard, Paris (Boy with Bottles)",
artist_id: "4",
year: "1954"
}
pry(main)> photograph = Photograph.new(attributes)
#=> #
pry(main)> photograph.id
#=> "1"
pry(main)> photograph.name
#=> "Rue Mouffetard, Paris (Boy with Bottles)"
pry(main)> photograph.artist_id
#=> "4"
pry(main)> photograph.year
#=> "1954"
pry(main)> attributes = {
id: "2",
name: "Ansel Adams",
born: "1902",
died: "1984",
country: "United States"
}
pry(main)> artist = Artist.new(attributes)
#=> #
pry(main)> artist.id
#=> "2"
pry(main)> artist.name
#=> "Ansel Adams"
pry(main)> artist.born
#=> "1902"
pry(main)> artist.died
#=> "1984"
pry(main)> artist.country
#=> "United States"
pry(main)> artist.age_at_death
#=> 82
```
### Iteration 2
```markdown
There are **3** points possible in Iteration 2:
4. Curator Creation (must include all attributes)
5. Curator #add_photograph & Curator #add_artist
6. Curator #find_artist_by_id
```
Use TDD to create a `Curator` class that responds to the following interaction pattern:
```ruby
pry(main)> require './lib/photograph'
# => true
pry(main)> require './lib/artist'
# => true
pry(main)> require './lib/curator'
# => true
pry(main)> curator = Curator.new
# => #
pry(main)> curator.photographs
# => []
pry(main)> photo_1 = Photograph.new({
id: "1",
name: "Rue Mouffetard, Paris (Boy with Bottles)",
artist_id: "1",
year: "1954"
})
# => #
pry(main)> photo_2 = Photograph.new({
id: "2",
name: "Moonrise, Hernandez",
artist_id: "2",
year: "1941"
})
# => #
pry(main)> curator.add_photograph(photo_1)
pry(main)> curator.add_photograph(photo_2)
pry(main)> curator.photographs
# => [#, #]
pry(main)> curator.artists
# => []
pry(main)> artist_1 = Artist.new({
id: "1",
name: "Henri Cartier-Bresson",
born: "1908",
died: "2004",
country: "France"
})
# => #
pry(main)> artist_2 = Artist.new({
id: "2",
name: "Ansel Adams",
born: "1902",
died: "1984",
country: "United States"
})
# => #
pry(main)> curator.add_artist(artist_1)
pry(main)> curator.add_artist(artist_2)
pry(main)> curator.artists
# => [#, #]
pry(main)> curator.find_artist_by_id("1")
# => #
```
### Iteration 3
```markdown
There are **3** points possible in Iteration 2:
7. Curator #photographs_by_artist
8. Curator #artists_with_multiple_photographs
9. Curator #photographs_taken_by_artist_from
```
Use TDD to update your `Curator` class so that is supports the following methods:
* `photographs_by_artist` - This method will return a hash with artists as keys, and an array of their photographs as values.
* `artists_with_multiple_photographs` - This method returns an Array of names of artists who have more than one photograph
* `photographs_taken_by_artists_from(string)` - This method takes a String representing a country. It returns an Array of `Photograph`s that were taken by a photographer from that country.
The `Curator` class should now respond to the following interaction pattern:
```ruby
pry(main)> require './lib/photograph'
# => true
pry(main)> require './lib/artist'
# => true
pry(main)> require './lib/curator'
# => true
pry(main)> curator = Curator.new
# => #
pry(main)> photo_1 = Photograph.new({
id: "1",
name: "Rue Mouffetard, Paris (Boy with Bottles)",
artist_id: "1",
year: "1954"
})
# => #
pry(main)> photo_2 = Photograph.new({
id: "2",
name: "Moonrise, Hernandez",
artist_id: "2",
year: "1941"
})
# => #
pry(main)> photo_3 = Photograph.new({
id: "3",
name: "Identical Twins, Roselle, New Jersey",
artist_id: "3",
year: "1967"
})
# => #
pry(main)> photo_4 = Photograph.new({
id: "4",
name: "Monolith, The Face of Half Dome",
artist_id: "3",
year: "1927"
})
# => #
pry(main)> artist_1 = Artist.new({
id: "1",
name: "Henri Cartier-Bresson",
born: "1908",
died: "2004",
country: "France"
})
# => #
pry(main)> artist_2 = Artist.new({
id: "2",
name: "Ansel Adams",
born: "1902",
died: "1984",
country: "United States"
})
# => #
pry(main)> artist_3 = Artist.new({
id: "3",
name: "Diane Arbus",
born: "1923",
died: "1971",
country: "United States"
})
# => #
pry(main)> curator.add_artist(artist_1)
pry(main)> curator.add_artist(artist_2)
pry(main)> curator.add_artist(artist_3)
pry(main)> curator.add_photograph(photo_1)
pry(main)> curator.add_photograph(photo_2)
pry(main)> curator.add_photograph(photo_3)
pry(main)> curator.add_photograph(photo_4)
pry(main)> curator.photographs_by_artist
# => {
# # => [#],
# # => [#],
# # => [#, #]
# }
pry(main)> curator.artists_with_multiple_photographs
# => ["Diane Arbus"]
pry(main)> curator.photographs_taken_by_artist_from("United States")
# => [#, #, #
pry(main)> curator.photographs_taken_by_artist_from("Argentina")
# => []
```
### Iteration 4
```markdown
There are **3** points possible in Iteration 2:
10. Curator #load_photographs && #load_artists
11. Curator #photographs_taken_between
12. Curator #artists_photographs_by_age
```
Use TDD to add the following methods to your `Curator` class:
* `load_photographs(file)` - This method takes a path to a CSV file containing photographs and adds them to the `Curator`. You may find the included `FileIO` class useful.
* `load_artists(file)` - This method takes a path to a CSV file containing artists and adds them to the `Curator`. You may find the included `FileIO` class useful.
* `photographs_taken_between(range)` - This method takes a range and returns an array of all photographs with a year that falls in that range.
* `artists_photographs_by_age(artist)`- This method takes an `Artist` object and return a hash where the keys are the Artists age when they took a photograph, and the values are the names of the photographs.
````ruby
pry(main)> require './lib/curator'
pry(main)> curator = Curator.new
#=> #
pry(main)> curator.load_photographs('./data/photographs.csv')
pry(main)> curator.load_artists('./data/artists.csv')
pry(main)> curator.photographs_taken_between(1950..1965)
#=> [#, #]
pry(main)> diane_arbus = curator.find_artist_by_id("3")
pry(main)> curator.artists_photographs_by_age(diane_arbus)
=> {44=>"Identical Twins, Roselle, New Jersey", 39=>"Child with Toy Hand Grenade in Central Park"}
```