Class: Booklist::Book
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Booklist::Book
- Defined in:
- lib/booklist/book.rb
Instance Method Summary collapse
Instance Method Details
#cli_display ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/booklist/book.rb', line 7 def cli_display puts "ID: #{id}\n" puts "Title: #{title}\n" puts "Author: #{author}\n" if puts "Additional authors: #{addn_authors}" if puts "State: #{state}" if state puts "Date Read: #{date_read.to_date.to_s}" if date_read puts "Tags: #{tag_list}\n" if .count > 0 puts "\n" end |
#tag_list ⇒ Object
18 19 20 21 |
# File 'lib/booklist/book.rb', line 18 def tag_list #put tags .map(&:name).join(", ") end |
#tag_list=(names) ⇒ Object
23 24 25 26 27 |
# File 'lib/booklist/book.rb', line 23 def tag_list=(names) self. = names.map do |n| Tag.where(name: n.strip).first_or_create! end end |