Module: Atheme::Parser
- Included in:
- ChanServ
- Defined in:
- lib/atheme/parser.rb
Defined Under Namespace
Modules: ChanServ
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/atheme/parser.rb', line 2 def self.included(klass) if klass.name.split('::').count > 3 service = klass.name.sub('Atheme::Parser::', '').gsub(/::.*/, '') command = klass.name.sub('Atheme::Parser::', '').gsub(/.*::/, '').downcase Atheme::PARSERS[service] ||= [] (Atheme::PARSERS[service] << command) unless command == '' Atheme::PARSERS[service].uniq! end end |
Instance Method Details
#command(name, &block) ⇒ Object
15 16 17 |
# File 'lib/atheme/parser.rb', line 15 def command(name, &block) @commands << [name, block] end |
#parse(name) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/atheme/parser.rb', line 19 def parse(name) @commands = [] create_parser(name) yield if block_given? create_commands if @commands.count > 0 end |