class Pug::Configuration
Defines parameters used to setup Pug
@!attribute type
@return [Integer] the type of client to setup @see Configuration::TERMINAL @see Configuration::TELEGRAM
@!attribute token
@return [String] the API token for Telegram @note This is optional if type is TERMINAL
@!attribute chat_id
@return [String] the chat_id for Telegram @note This is optional if type is TERMINAL
@!attribute actions
@return [Array<Interfaces::Action>] user defined actions
Constants
- TELEGRAM
- TERMINAL
@!group Client
Types
Attributes
actions[RW]
chat_id[RW]
token[RW]
type[RW]
Public Class Methods
new(type = TERMINAL)
click to toggle source
@param type [Integer] type of client to setup
# File lib/pug/configuration.rb, line 26 def initialize(type = TERMINAL) @type = type end
Public Instance Methods
validate()
click to toggle source
Validates if attributes are correctly setup for Pug
@raise RuntimeError if type is not a valid Client type @raise RuntimeError if Telegram client and no token & chat_id
@raise RuntimeError if provided actions are nil @return [void]
# File lib/pug/configuration.rb, line 35 def validate valid_type = [TERMINAL, TELEGRAM].include?(type) raise 'Invalid client type' unless valid_type bad_config = @token.nil? || @chat_id.nil? raise 'Invalid Telegram config' if @type == TELEGRAM && bad_config raise 'No actions provided' if @actions.nil? end