Class: Cinch::Rubydoc

Inherits:
Object
  • Object
show all
Includes:
Plugin
Defined in:
lib/cinch/rubydoc.rb

Constant Summary collapse

BASE_URL =
'http://www.rubydoc.info/stdlib'

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Rubydoc

Returns a new instance of Rubydoc.



12
13
14
15
16
# File 'lib/cinch/rubydoc.rb', line 12

def initialize(*args)
    super
    @store = YARD::RegistryStore.new
    @store.load '.yardoc'
end

Instance Method Details

#execute(m, request) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cinch/rubydoc.rb', line 18

def execute(m, request)
    requests = request.split /[ ,]+/
    if requests.count > 3
        requests = requests.first(3)
    end

    uris = requests.map do |request|
        url_for(request)
    end

    uris.compact!
    if uris.empty?
        m.reply 'No results'
    else
        m.reply uris.join ', '
    end
end