Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/technical_graph/array.rb

Overview

Instance Method Summary collapse

Instance Method Details

#clone_partial_w_fill(_from, _to) ⇒ Object

Create partial array and fill with border values if needed



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/technical_graph/array.rb', line 16

def clone_partial_w_fill(_from, _to)
  part_array = Array.new
  # border = false

  (_from.._to).each do |current_i|
    # outside ranges
    if current_i < 0
      part_array << self.first
      # border = true
      next
    end

    if self.size <= current_i
      part_array << self.last
      # border = true
      next
    end

    part_array << self[current_i]
  end

  return part_array
end

#float_meanObject



11
12
13
# File 'lib/technical_graph/array.rb', line 11

def float_mean
  float_sum / size
end

#float_sumObject



7
8
9
# File 'lib/technical_graph/array.rb', line 7

def float_sum
  inject(0.0) { |result, el| result + el }
end