20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/arrow/field-containable.rb', line 20
def find_field(name_or_index)
case name_or_index
when String, Symbol
name = name_or_index
get_field_by_name(name)
when Integer
index = name_or_index
raise if index < 0
index += n_fields if index < 0
return nil if index < 0 or index >= n_fields
get_field(index)
else
message = +"field name or index must be String, Symbol or Integer"
message << ": <#{name_or_index.inspect}>"
raise ArgumentError, message
end
end
|