Class: Tkellem::TkellemBot::ListenCommand

Inherits:
CRUDCommand show all
Defined in:
lib/tkellem/tkellem_bot.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #bouncer, #conn, #options, #opts

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CRUDCommand

#execute, #find_attributes, #list, #modify, register_crud, #remove, #show

Methods inherited from Command

admin_only?, admin_option, admin_user?, build_options, #initialize, option, register, resources, #respond, run, #show_help, #user

Constructor Details

This class inherits a constructor from Tkellem::TkellemBot::Command

Class Method Details

.get_uri(arg) ⇒ Object



214
215
216
217
218
219
220
221
222
223
# File 'lib/tkellem/tkellem_bot.rb', line 214

def self.get_uri(arg)
  require 'uri'
  uri = URI.parse(arg)
  unless %w(irc ircs).include?(uri.scheme)
    raise Command::ArgumentError, "Invalid URI scheme: #{uri}"
  end
  uri
rescue URI::InvalidURIError
  raise Command::ArgumentError, "Invalid new address: #{arg}"
end

Instance Method Details

#attributesObject



225
226
227
228
# File 'lib/tkellem/tkellem_bot.rb', line 225

def attributes
  uri = self.class.get_uri(args.first)
  { :address => uri.host, :port => uri.port, :ssl => (uri.scheme == 'ircs') }
end