module FFaker::Book

Public Instance Methods

author() click to toggle source
# File lib/ffaker/book.rb, line 21
def author
  FFaker::Name.name
end
cover(*args, slug: nil, size: '300x300', format: 'png', bgset: nil) click to toggle source
# File lib/ffaker/book.rb, line 33
def cover(*args, slug: nil, size: '300x300', format: 'png', bgset: nil)
  if args.any?
    warn "Positional arguments for Book##{__method__} are deprecated. Please use keyword arguments."
    slug = args[0]
    size = args[1] if args.size > 1
    format = args[2] if args.size > 2
    bgset = args[3] if args.size > 3
  end

  FFaker::Avatar.image(slug: slug, size: size, format: format, bgset: bgset)
end
description(sentence_count = 3) click to toggle source
# File lib/ffaker/book.rb, line 29
def description(sentence_count = 3)
  FFaker::Lorem.paragraph(sentence_count)
end
genre() click to toggle source
# File lib/ffaker/book.rb, line 17
def genre
  fetch_sample(GENRES)
end
isbn() click to toggle source
# File lib/ffaker/book.rb, line 25
def isbn
  rand(1_000_000_000...25_000_000_000).to_s
end
orly_cover(name = title, book_author = author, top_text = genre) click to toggle source
# File lib/ffaker/book.rb, line 45
def orly_cover(name = title, book_author = author, top_text = genre)
  'https://orly-appstore.herokuapp.com/generate?' \
    "title=#{CGI.escape(name)}&" \
    "top_text=#{CGI.escape(top_text)}&" \
    "author=#{CGI.escape(book_author)}&" \
    "image_code=#{Random.rand(1..40)}&" \
    "theme=#{Random.rand(1..16)}"
end
title() click to toggle source
# File lib/ffaker/book.rb, line 10
def title
  case rand(0..1)
  when 0 then simple_title
  when 1 then title_with_prefix
  end
end

Private Instance Methods

simple_title() click to toggle source
# File lib/ffaker/book.rb, line 56
def simple_title
  "#{fetch_sample(ADJ_AND_ADV)} #{fetch_sample(NOUNS)}"
end
title_with_prefix() click to toggle source
# File lib/ffaker/book.rb, line 60
def title_with_prefix
  "#{fetch_sample(PREFIXES)} #{simple_title}"
end