Class: Yarr::Command::Ri

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

Overview

Base class for all ri commands

Direct Known Subclasses

RiCall, RiClassName, RiMethodName

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?


25
26
27
# File 'lib/yarr/command/ri.rb', line 25

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

Instance Method Details

#handleObject


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

def handle
  response(query)
end

#response(dataset) ⇒ String

Responds with a string for the dataset. When the dataset is empty or has many items 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_single_item_responder


17
# File 'lib/yarr/command/ri.rb', line 17

define_single_item_responder { |result| result.first.url }