Class: Hypertube::Sdk::Tools::GetInstanceFieldHelper
- Inherits:
-
Object
- Object
- Hypertube::Sdk::Tools::GetInstanceFieldHelper
- Defined in:
- lib/hypertube-ruby-sdk/sdk/tools/get_instance_field_helper.rb
Class Method Summary collapse
Class Method Details
.get_field_value(command, field_name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hypertube-ruby-sdk/sdk/tools/get_instance_field_helper.rb', line 11 def get_field_value(command, field_name) return nil if command.nil? || command.payload.nil? || command.payload.empty? if command.command_type == Hypertube::Utils::CommandType::SET_INSTANCE_FIELD && command.payload.length >= 3 name = get_payload_value(command.payload[1]) return get_payload_value(command.payload[2]) if name.is_a?(String) && name == field_name end if command.command_type == Hypertube::Utils::CommandType::ARRAY command.payload.each do |item| if item.is_a?(Hypertube::Utils::Command) result = get_field_value(item, field_name) return result unless result.nil? end end return nil end first_payload = command.payload[0] return get_field_value(first_payload, field_name) if first_payload.is_a?(Hypertube::Utils::Command) nil end |
.get_result_type(command) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hypertube-ruby-sdk/sdk/tools/get_instance_field_helper.rb', line 35 def get_result_type(command) return nil if command.nil? || command.payload.nil? || command.payload.empty? if [ Hypertube::Utils::CommandType::GET_RESULT_TYPE, Hypertube::Utils::CommandType::GET_TYPE, Hypertube::Utils::CommandType::COMPLEX_VALUE_TYPE ].include?(command.command_type) val = get_payload_value(command.payload[0]) return val if val.is_a?(String) return nil end if command.command_type == Hypertube::Utils::CommandType::ARRAY command.payload.each do |item| if item.is_a?(Hypertube::Utils::Command) result = get_result_type(item) return result unless result.nil? end end return nil end first_payload = command.payload[0] return get_result_type(first_payload) if first_payload.is_a?(Hypertube::Utils::Command) nil end |