Class: TelegramBot::ApiResponse
- Inherits:
-
Object
- Object
- TelegramBot::ApiResponse
- Defined in:
- lib/telegram_bot/api_response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#ok ⇒ Object
(also: #ok?)
readonly
Returns the value of attribute ok.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(res) ⇒ ApiResponse
constructor
A new instance of ApiResponse.
Constructor Details
#initialize(res) ⇒ ApiResponse
Returns a new instance of ApiResponse.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/telegram_bot/api_response.rb', line 5 def initialize(res) @body = res.body if res.status == 200 data = JSON.parse(body) @ok = data["ok"] @result = data["result"] else @ok = false end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/telegram_bot/api_response.rb', line 3 def body @body end |
#ok ⇒ Object (readonly) Also known as: ok?
Returns the value of attribute ok.
3 4 5 |
# File 'lib/telegram_bot/api_response.rb', line 3 def ok @ok end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/telegram_bot/api_response.rb', line 3 def result @result end |