class Kybus::Bot::Command

Object that wraps a command, it is analogus to a route definition. it currently only gets a param list, but it will be extended to a more complex DSL.

Attributes

block[R]

Public Class Methods

new(params, block) click to toggle source

Receives a list of params as symbols and the lambda with the block.

# File lib/kybus/bot/command_definition.rb, line 12
def initialize(params, block)
  @params = params
  @block = block
end

Public Instance Methods

next_missing_param(current_params) click to toggle source

Finds the first empty param from the given parameter

# File lib/kybus/bot/command_definition.rb, line 23
def next_missing_param(current_params)
  @params.find { |key| !current_params.key?(key) }
end
ready?(current_params) click to toggle source

Checks if the params object given contains all the needed values

# File lib/kybus/bot/command_definition.rb, line 18
def ready?(current_params)
  @params.all? { |key| current_params.key?(key) }
end