Class: Moon::DataMatrix::Iterator

Inherits:
Object
  • Object
show all
Defined in:
lib/moon/packages/data_bags/data_matrix.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src) ⇒ Iterator

Returns a new instance of Iterator.


11
12
13
# File 'lib/moon/packages/data_bags/data_matrix.rb', line 11

def initialize(src)
  @src = src
end

Instance Attribute Details

#srcObject (readonly)

Returns the value of attribute src


9
10
11
# File 'lib/moon/packages/data_bags/data_matrix.rb', line 9

def src
  @src
end

Instance Method Details

#each(&block) ⇒ Object


15
16
17
# File 'lib/moon/packages/data_bags/data_matrix.rb', line 15

def each(&block)
  src.data.each(&block)
end

#each_with_xyzself

Returns:

  • (self)

20
21
22
23
24
25
26
27
28
# File 'lib/moon/packages/data_bags/data_matrix.rb', line 20

def each_with_xyz
  src.zsize.times do |z|
    src.ysize.times do |y|
      src.xsize.times do |x|
        yield src.data[x + y * src.xsize + z * src.xsize * src.ysize], x, y, z
      end
    end
  end
end