Module: IIRC::Parsing

Included in:
Bot
Defined in:
lib/iirc/modules/parsing.rb

Instance Method Summary collapse

Instance Method Details

#parse(line) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/iirc/modules/parsing.rb', line 3

def parse(line)
  Event.new.tap { |evt|
    words = line.chomp.split " "

    if words[0] and words[0].start_with? ":"
      evt.sender = words.shift[1..]
    end

    evt.verb = words.shift.downcase.to_sym

    while word = words.shift
      if word.start_with? ':'
        evt.args << [word[1..], *words].join(' ')
        break
      else
        evt.args << word
      end
    end
  }
end