Module: Chatterbot::Utils

Included in:
Bot
Defined in:
lib/chatterbot/utils.rb

Overview

Assorted handy utility methods

Instance Method Summary collapse

Instance Method Details

#id_from_tweet(t) ⇒ Object

return the id of a tweet, or the incoming object (likely already an ID)

Parameters:

  • t (Tweet)

    the Tweet



11
12
13
# File 'lib/chatterbot/utils.rb', line 11

def id_from_tweet(t)
  t.is_a?(Twitter::Tweet) ? t.id : t
end

#id_from_user(u) ⇒ Object

return the id of a User, or the incoming object (likely already an ID)

Parameters:

  • u (User)

    the User



20
21
22
# File 'lib/chatterbot/utils.rb', line 20

def id_from_user(u)
  u.is_a?(Twitter::User) ? u.id : u
end