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(*args) ⇒ Object



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

def new(*args)
  builder_class_name = "#{name}Builder"
  if const_defined?(builder_class_name)
    builder_class = const_get(builder_class_name)
    if args.size == builder_class.method(:build).arity
      builder_class.build(*args)
    else
      super
    end
  else
    super
  end
end

Instance Method Details

#[](i) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/arrow/array.rb', line 38

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

#eachObject



47
48
49
50
51
52
53
# File 'lib/arrow/array.rb', line 47

def each
  return to_enum(__method__) unless block_given?

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

#reverse_eachObject



55
56
57
58
59
60
61
# File 'lib/arrow/array.rb', line 55

def reverse_each
  return to_enum(__method__) unless block_given?

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

#to_arrowObject



63
64
65
# File 'lib/arrow/array.rb', line 63

def to_arrow
  self
end