class Booklist::Book

Public Instance Methods

cli_display() click to toggle source
# File lib/booklist/book.rb, line 7
def cli_display
  puts "ID: #{id}\n"
  puts "Title: #{title}\n"
  puts "Author: #{author}\n" if author
  puts "Additional authors: #{addn_authors}" if addn_authors
  puts "State: #{state}" if state
  puts "Date Read: #{date_read.to_date.to_s}" if date_read
  puts "Tags: #{tag_list}\n" if tags.count > 0
  puts "\n"
end
tag_list() click to toggle source
# File lib/booklist/book.rb, line 18
def tag_list
  #put tags
  tags.map(&:name).join(", ")
end
tag_list=(names) click to toggle source
# File lib/booklist/book.rb, line 23
def tag_list=(names)
  self.tags = names.map do |n|
    Tag.where(name: n.strip).first_or_create!
  end
end