class Pug::Clients::Factory

Factory for building Clients based on a configuration

Public Class Methods

client_for_config(config) click to toggle source

Builds a Client for the given config @param config [Configuration] parameters to build Client from @return [Interfaces::Client] The client from the config parameters

# 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