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, Fake, List, Ri, URLEvaluate

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ast) ⇒ Base

Creates a command that handles the parsed input

Parameters:

  • ast (Yarr:AST)

    the parsed input


10
11
12
# File 'lib/yarr/command/base.rb', line 10

def initialize(ast)
  @ast = ast
end

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast


16
17
18
# File 'lib/yarr/command/base.rb', line 16

def ast
  @ast
end

Instance Method Details

#handleObject

Runs the command


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

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