Class: Yarr::Command::Fake

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

Overview

Exposing the faker gem as a bot command

Instance Attribute Summary

Attributes inherited from Base

#ast

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concern::ASTDigger

digger

Methods inherited from Base

#initialize

Constructor Details

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

Class Method Details

.match?(ast) ⇒ Boolean


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

def self.match?(ast)
  ast[:command] == 'fake' && ast.key?(:class_method)
end

Instance Method Details

#handleObject


17
18
19
20
21
22
23
# File 'lib/yarr/command/fake.rb', line 17

def handle
  Faker.const_get(class_name).send(method_name).to_s
rescue NameError
  'No suitable faker found. The list is at ' \
  'https://github.com/stympy/faker with the restriction that I need ' \
  'Classname.methodname.'
end