Class: Tarantool::TranslateToHash
- Inherits:
-
Struct
- Object
- Struct
- Tarantool::TranslateToHash
- Defined in:
- lib/tarantool/response.rb
Overview
note that :_tail should not be in field_names
Instance Attribute Summary collapse
-
#field_names ⇒ Object
Returns the value of attribute field_names.
-
#tail_size ⇒ Object
Returns the value of attribute tail_size.
Instance Method Summary collapse
Instance Attribute Details
#field_names ⇒ Object
Returns the value of attribute field_names
167 168 169 |
# File 'lib/tarantool/response.rb', line 167 def field_names @field_names end |
#tail_size ⇒ Object
Returns the value of attribute tail_size
167 168 169 |
# File 'lib/tarantool/response.rb', line 167 def tail_size @tail_size end |
Instance Method Details
#call(tuple) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/tarantool/response.rb', line 168 def call(tuple) i = 0 hash = {} tuple_size = tuple.size names = field_names while i < tuple_size if name = names[i] hash[name] = tuple[i] else tail = tuple.slice(i..-1) hash[:_tail] = tail_size == 1 ? tail : tail.each_slice(tail_size).to_a break end i += 1 end hash end |