Class: Pug::Clients::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/pug/clients/factory.rb

Overview

Factory for building Clients based on a configuration

Class Method Summary collapse

Class Method Details

.client_for_config(config) ⇒ Interfaces::Client

Builds a Client for the given config

Parameters:

Returns:



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pug/clients/factory.rb', line 10

def self.client_for_config(config)
  if !config.nil? && config.type == Configuration::TELEGRAM
    enumerator = Action::Enumerator.new
    markup = enumerator.grouped_names(config.actions)
    client = TelegramClient.new(config.token, config.chat_id)
    client.configure_keyboard(markup)
    client
  else
    TerminalClient.new
  end
end