Class: Feedig::Session
- Inherits:
-
Net::IRC::Server::Session
- Object
- Net::IRC::Server::Session
- Feedig::Session
- Defined in:
- lib/feedig/session.rb
Instance Method Summary collapse
- #channels ⇒ Object
- #client ⇒ Object
-
#initialize(*args) ⇒ Session
constructor
A new instance of Session.
- #on_disconnected ⇒ Object
- #on_user(m) ⇒ Object
- #server_version ⇒ Object
Constructor Details
#initialize(*args) ⇒ Session
Returns a new instance of Session.
16 17 18 |
# File 'lib/feedig/session.rb', line 16 def initialize(*args) super end |
Instance Method Details
#channels ⇒ Object
12 13 14 |
# File 'lib/feedig/session.rb', line 12 def channels ['#notification'] end |
#client ⇒ Object
20 21 22 23 24 25 |
# File 'lib/feedig/session.rb', line 20 def client @client ||= YAML.load_file('./lib/feedig/resources.yml').inject({}) { |hash, (name, url)| hash[name] = Feedzirra::Feed.fetch_and_parse url hash } end |
#on_disconnected ⇒ Object
27 28 29 |
# File 'lib/feedig/session.rb', line 27 def on_disconnected @retrieve_thread.kill rescue nil end |
#on_user(m) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/feedig/session.rb', line 31 def on_user(m) super channels.each { |channel| post @nick, JOIN, channel } client.each_pair do |name, feed| post( "RECENT", PRIVMSG, "#notification", "\0035#{name}:\017 \00314#{feed.entries[0].title} [ #{feed.entries[0].url} ] #{feed.entries[0].last_modified}\017" ) end @retrieve_thread = Thread.start do loop do retrieve @opts.interval end end end |