Class: Diligence::Application
- Inherits:
-
Object
- Object
- Diligence::Application
- Defined in:
- lib/diligence/application.rb
Instance Method Summary collapse
-
#initialize(root_path) ⇒ Application
constructor
A new instance of Application.
- #run ⇒ Object
Constructor Details
#initialize(root_path) ⇒ Application
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/diligence/application.rb', line 3 def initialize(root_path) @root_path = root_path @loader = Zeitwerk::Loader.new @loader.push_dir(File.join(@root_path, 'app')) @loader.enable_reloading @loader.setup token = ENV['TG_TOKEN'] raise 'TG_TOKEN environment variable is not set' unless token @api_client = ApiClient.new(token) @offset = nil @router = load_routes end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/diligence/application.rb', line 19 def run loop do updates = @api_client.get_updates(offset: @offset) updates.each do |update| if update.include?('message') = Types::Updates::MessageUpdate.new(update) () end @offset = update['update_id'] + 1 end end end |