Class: Robut::Plugin::Quips
- Inherits:
-
Object
- Object
- Robut::Plugin::Quips
- Includes:
- Robut::Plugin
- Defined in:
- lib/robut/plugin/quips.rb
Overview
Stores quotes and replies with a random stored quote.
Instance Attribute Summary
Attributes included from Robut::Plugin
#connection, #private_sender, #reply_to
Instance Method Summary collapse
-
#add_quip(quip) ⇒ Object
Adds
quipto the quip database. -
#quips ⇒ Object
The list of quips stored in the quip database.
-
#quips=(new_quips) ⇒ Object
Update the list of quips stored in the quip database.
-
#random_quip ⇒ Object
Returns a random quip.
-
#remove_quip(quip) ⇒ Object
Removes
quipfrom the quip database.
Methods included from Robut::Plugin
#at_nick, #fake_message, #handle, included, #initialize, #nick, #reply, #sent_to_me?, #store, #usage, #without_nick, #words
Instance Method Details
#add_quip(quip) ⇒ Object
Adds quip to the quip database
46 47 48 |
# File 'lib/robut/plugin/quips.rb', line 46 def add_quip(quip) self.quips = (quips + Array(quip)) unless quips.include?(quip) end |
#quips ⇒ Object
The list of quips stored in the quip database
34 35 36 37 |
# File 'lib/robut/plugin/quips.rb', line 34 def quips # I'd love to use a set here, but it doesn't serialize right to yaml store["quips"] ||= [] end |
#quips=(new_quips) ⇒ Object
Update the list of quips stored in the quip database
40 41 42 43 |
# File 'lib/robut/plugin/quips.rb', line 40 def quips=(new_quips) # I'd love to use a set here, but it doesn't serialize right to yaml store["quips"] = new_quips end |
#random_quip ⇒ Object
Returns a random quip
56 57 58 |
# File 'lib/robut/plugin/quips.rb', line 56 def random_quip quips[rand(quips.length)] unless quips.empty? end |
#remove_quip(quip) ⇒ Object
Removes quip from the quip database
51 52 53 |
# File 'lib/robut/plugin/quips.rb', line 51 def remove_quip(quip) self.quips = (quips - Array(quip)) if quips.include?(quip) end |