Class: Yarr::Command::List

Inherits:
Base
  • Object
show all
Extended by:
Concern::ASTDigger
Includes:
Concern::Responder
Defined in:
lib/yarr/command/list.rb

Overview

Base class for all list commands

Direct Known Subclasses

ListCall, ListClassName, ListMethodName

Instance Attribute Summary

Attributes inherited from Base

#ast

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concern::ASTDigger

digger

Methods included from Concern::Responder

#advice

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Yarr::Command::Base

Class Method Details

.match?(ast) ⇒ Boolean

Can we handle the given AST?

Parameters:

  • ast (hash)

    parsed AST

Returns:

  • (Boolean)

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

def self.match?(ast)
  ast[:command] == 'list'
end

Instance Method Details

#handleObject

Command handler


22
23
24
# File 'lib/yarr/command/list.rb', line 22

def handle
  response(query)
end

#response(dataset) ⇒ String

Responds with a string for the dataset. When the dataset is empty our response would report back that to the user, otherwise the client code defines what the response should be. This method was defined by define_multi_item_responder

Parameters:

  • dataset (Array)

    the dataset we respond to

Returns:

  • (String)

    message to the user


17
18
19
# File 'lib/yarr/command/list.rb', line 17

define_multi_item_responder do |result|
  result.map(&:full_name).join(', ')
end