Class: Arrow::Array

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/arrow/array.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(values) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/arrow/array.rb', line 23

def new(values)
  builder_class_name = "#{name}Builder"
  if const_defined?(builder_class_name)
    builder_class = const_get(builder_class_name)
    builder_class.build(values)
  else
    super
  end
end

Instance Method Details

#[](i) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/arrow/array.rb', line 34

def [](i)
  i += length if i < 0
  if null?(i)
    nil
  else
    get_value(i)
  end
end

#eachObject



43
44
45
46
47
48
49
# File 'lib/arrow/array.rb', line 43

def each
  return to_enum(__method__) unless block_given?

  length.times do |i|
    yield(self[i])
  end
end

#reverse_eachObject



51
52
53
54
55
56
57
# File 'lib/arrow/array.rb', line 51

def reverse_each
  return to_enum(__method__) unless block_given?

  (length - 1).downto(0) do |i|
    yield(self[i])
  end
end

#to_arrowObject



59
60
61
# File 'lib/arrow/array.rb', line 59

def to_arrow
  self
end