Class: Roflbot::SentenceBot

Inherits:
Base
  • Object
show all
Defined in:
lib/roflbot/sentence_bot.rb

Constant Summary

Constants inherited from Base

Base::TWITTER

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#expects, #on_im, #respond_via_sms, #respond_via_twitter, #start, #stop, #wait

Constructor Details

#initialize(*args) ⇒ SentenceBot

Returns a new instance of SentenceBot.



5
6
7
8
9
10
11
12
13
14
# File 'lib/roflbot/sentence_bot.rb', line 5

def initialize(*args)
  super
  parser = SentenceParser.new
  @sentences = []
  @options["sentences"].each do |sentence|
    node = parser.parse(sentence)
    @sentences << node
  end
  self.expects(/^.*$/).responds { generated_message }
end

Instance Method Details

#generated_messageObject



16
17
18
19
# File 'lib/roflbot/sentence_bot.rb', line 16

def generated_message
  node = @sentences[rand(@sentences.length)]
  node.to_s(@options)
end