Class: Yarr::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/yarr/command/base.rb

Overview

Generic base class for command handling.

A command receives a parsed AST from the bot and responds with some string to it.

Direct Known Subclasses

Evaluate, Fact, Fake, List, Ops, Renick, Ri, URLEvaluate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ast:, irc: NoIRC) ⇒ Base

Creates a command that handles the parsed input


13
14
15
16
# File 'lib/yarr/command/base.rb', line 13

def initialize(ast:, irc: NoIRC)
  @ast = ast
  @irc = irc
end

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast


24
25
26
# File 'lib/yarr/command/base.rb', line 24

def ast
  @ast
end

#ircObject (readonly)

Returns the value of attribute irc


20
21
22
# File 'lib/yarr/command/base.rb', line 20

def irc
  @irc
end

Class Method Details

.match?(_ast) ⇒ Boolean

Can we handle the given AST?


28
29
30
# File 'lib/yarr/command/base.rb', line 28

def self.match?(_ast)
  false
end

Instance Method Details

#handleObject

Runs the command


33
34
35
# File 'lib/yarr/command/base.rb', line 33

def handle
  "#{self.class} doesn't know how to handle #{ast}"
end