Class: Vkponchik::Response
- Inherits:
-
Object
- Object
- Vkponchik::Response
- Defined in:
- lib/vkponchik/response.rb
Overview
API response
Instance Method Summary collapse
- #[](arg) ⇒ Object?
- #error? ⇒ Boolean
- #error_full_message ⇒ String?
-
#initialize(hash) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ Response
Returns a new instance of Response.
7 8 9 |
# File 'lib/vkponchik/response.rb', line 7 def initialize(hash) @hash = hash end |
Instance Method Details
#[](arg) ⇒ Object?
29 30 31 |
# File 'lib/vkponchik/response.rb', line 29 def [](arg) @hash[arg.to_s] end |
#error? ⇒ Boolean
12 13 14 |
# File 'lib/vkponchik/response.rb', line 12 def error? !@hash['success'] end |
#error_full_message ⇒ String?
22 23 24 25 26 |
# File 'lib/vkponchik/response.rb', line 22 def return unless error? "#{@hash['error']}: #{@hash['msg']}" end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/vkponchik/response.rb', line 17 def success? !error? end |