Skip to content

Commit

Permalink
fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasesquivelgc committed Oct 20, 2023
1 parent 3ac5c46 commit cb3ede9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def display_options
end
end
end

def number?(obj)
obj = obj.to_s unless obj.is_a? String
/\A[+-]?\d+(\.\d+)?\z/.match(obj)
Expand All @@ -61,6 +62,7 @@ def process_input(option)
show_error
end
end

def list_books
if @books.empty?
puts 'No books available.'
Expand All @@ -72,23 +74,27 @@ def list_books
end
end
end

def list_albums
if @albums.empty?
puts 'No albums available.'
else
List.list_items(@albums)
end
end

def list_games
if @games.empty?
puts 'No games available.'
else
List.list_items(@games)
end
end

def list_genres
List.list_genres(@genres)
end

def list_authors
if @authors.empty?
puts 'No authors available.'
Expand All @@ -98,6 +104,7 @@ def list_authors
end
end
end

def list_labels
if @labels.empty?
puts 'No labels available.'
Expand All @@ -109,6 +116,7 @@ def list_labels
end
end
end

def add_album
album_publish_date = verify_publish_date
album = MusicAlbum.new(album_publish_date)
Expand All @@ -119,6 +127,7 @@ def add_album
puts 'Album added successfully!'
puts '----------------------------------------------'
end

def add_book
print 'Publisher: '
publisher = gets.chomp
Expand All @@ -143,6 +152,7 @@ def add_book
@books << book
SaveBook.save_book(book)
end

def add_game
game_publish_date = verify_publish_date
puts 'Thats the game has multiplayer? (y/n)'
Expand All @@ -156,39 +166,49 @@ def add_game
puts 'Game added successfully!!!'
puts '----------------------------------------------'
end

def valid_date?(date_str)
date_str.match?(/^\d{4}-\d{2}-\d{2}$/)
end

def verify_publish_date(prompt = 'Enter the publish date of the item (YYYY-MM-DD):')
publish_date = ''
loop do
puts prompt
publish_date = gets.chomp
break if valid_date?(publish_date)

puts 'Invalid date! Please enter a valid date in the format YYYY-MM-DD.'
end
publish_date
end

def load_games_from_json
SaveGame.load_games_from_json
end

def load_albums_from_json
SaveAlbum.load_albums
end

def load_genres_from_json
SaveGenre.load_genres
end

def load_labels_from_json
SaveLabel.load_labels
end

def load_books_from_json
SaveBook.load_books
end

def show_error
puts 'Error! Please select a valid option.'
end

def quit
puts 'Saving your data ...'
exit
end
end
end
2 changes: 1 addition & 1 deletion spec/author_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
expect(item).to have_received(:author=).with(subject)
end
end
end
end

0 comments on commit cb3ede9

Please sign in to comment.