Module: Telegram::Bot::Client::ApiHelper
- Included in:
- Telegram::Bot::Client
- Defined in:
- lib/telegram/bot/client/api_helper.rb
Constant Summary collapse
- METHODS_LIST_FILE =
File.('../api_methods.txt', __FILE__)
Class Method Summary collapse
-
.define_helpers(*list) ⇒ Object
Defines method with underscored name to post to specific endpoint:.
- .methods_list(file = METHODS_LIST_FILE) ⇒ Object
Class Method Details
.define_helpers(*list) ⇒ Object
Defines method with underscored name to post to specific endpoint:
define_method :getMe
# defines #get_me
20 21 22 23 24 |
# File 'lib/telegram/bot/client/api_helper.rb', line 20 def define_helpers(*list) list.map(&:to_s).each do |method| define_method(method.underscore) { |*args| request(method, *args) } end end |
.methods_list(file = METHODS_LIST_FILE) ⇒ Object
10 11 12 13 14 |
# File 'lib/telegram/bot/client/api_helper.rb', line 10 def methods_list(file = METHODS_LIST_FILE) File.read(file).lines. map(&:strip). reject { |x| x.empty? || x.start_with?('#') } end |