Class: TonClient::TonBinding::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/ton-client-ruby/Binding/binding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(core: TonClient::TonBinding) ⇒ Response

Returns a new instance of Response.



10
11
12
# File 'lib/ton-client-ruby/Binding/binding.rb', line 10

def initialize(core: TonClient::TonBinding)
  @core = core
end

Instance Attribute Details

#coreObject (readonly)

Returns the value of attribute core.



7
8
9
# File 'lib/ton-client-ruby/Binding/binding.rb', line 7

def core
  @core
end

#current_responseObject

Returns the value of attribute current_response.



8
9
10
# File 'lib/ton-client-ruby/Binding/binding.rb', line 8

def current_response
  @current_response
end

#custom_responseObject

Returns the value of attribute custom_response.



8
9
10
# File 'lib/ton-client-ruby/Binding/binding.rb', line 8

def custom_response
  @custom_response
end

#errorObject

Returns the value of attribute error.



8
9
10
# File 'lib/ton-client-ruby/Binding/binding.rb', line 8

def error
  @error
end

#finishedObject

Returns the value of attribute finished.



8
9
10
# File 'lib/ton-client-ruby/Binding/binding.rb', line 8

def finished
  @finished
end

#request_idObject

Returns the value of attribute request_id.



8
9
10
# File 'lib/ton-client-ruby/Binding/binding.rb', line 8

def request_id
  @request_id
end

#resultObject

Returns the value of attribute result.



8
9
10
# File 'lib/ton-client-ruby/Binding/binding.rb', line 8

def result
  @result
end

Instance Method Details

#update(request_id, string_data, response_type, finished) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ton-client-ruby/Binding/binding.rb', line 14

def update(request_id, string_data, response_type, finished)
  response_hash = core.read_string_to_hash(string_data)
  self.finished = finished
  self.request_id = request_id
  self.current_response = response_hash
  case response_type
  when 0
    # result
    self.result = response_hash
  when 1
    # error
    self.error = response_hash
  else
    # another
    if response_type >= 100
      self.custom_responses = response_hash
    end
  end
end