class Quotify::Quote
This class represents a quote object
Public Class Methods
new(quote: nil, author: nil)
click to toggle source
Generates a quote @param quote [#to_s] A specified quote @param author [#to_s] A specified author @return [Quote] quote with author
# File lib/quotify/quote.rb, line 14 def initialize(quote: nil, author: nil) @quote = quote || Quotify.config[:quotes].sample @author = author || Quotify.config[:authors].sample end
Public Instance Methods
quote()
click to toggle source
Returns the quote @return [#to_s]
# File lib/quotify/quote.rb, line 52 def quote @quote end
to_hash()
click to toggle source
Returns the quote and author in a hash @return [Hash]
# File lib/quotify/quote.rb, line 34 def to_hash { quote: @quote, author: @author } end
Also aliased as: to_h
to_json()
click to toggle source
Returns the quote and author in a JSON structured String @return [String]
# File lib/quotify/quote.rb, line 40 def to_json to_hash.to_json end
to_s(spacer: Quotify.config[:default_spacer])
click to toggle source
Returns the quote and author in a string format @option spacer [#to_s] Characters between quote and author
# File lib/quotify/quote.rb, line 21 def to_s(spacer: Quotify.config[:default_spacer]) "#{@quote}#{spacer}#{@author}" end
to_str(spacer: Quotify.config[:default_spacer])
click to toggle source
Returns the quote and author in a string format @option spacer [#to_s] Characters between quote and author
# File lib/quotify/quote.rb, line 28 def to_str(spacer: Quotify.config[:default_spacer]) to_s(spacer: spacer) end