module RenderCow::RenderCowPatch

Public Instance Methods

render(options = {}, args = {}) click to toggle source
Calls superclass method
# File lib/render_cow/render_cow_patch.rb, line 4
def render(options = {}, args = {})
  options[:plain] = cowspeach(options).then { RenderCow.moo(_1, character) } if character?(options)
  super
end

Private Instance Methods

character(options = {}) click to toggle source
# File lib/render_cow/render_cow_patch.rb, line 11
def character(options = {})
  options[:cow] = options.delete(:cowsay) if options.key?(:cowsay)
  @character ||= options.detect do |key, _value|
    RenderCow.characters.find { _1 == key }
  end&.first
end
character?(options) click to toggle source
# File lib/render_cow/render_cow_patch.rb, line 18
def character?(options)
  return unless options.is_a?(Hash)

  character(options).present?
end
cowspeach(options = {}) click to toggle source
# File lib/render_cow/render_cow_patch.rb, line 24
def cowspeach(options = {})
  speach = options[character]
  character == :spongebob ? speach.spongebobify : speach
end