Class: Spandx::Core::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/spandx/core/relation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, index) ⇒ Relation

Returns a new instance of Relation.



8
9
10
11
# File 'lib/spandx/core/relation.rb', line 8

def initialize(io, index)
  @io = io
  @index = index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



6
7
8
# File 'lib/spandx/core/relation.rb', line 6

def index
  @index
end

#ioObject (readonly)

Returns the value of attribute io.



6
7
8
# File 'lib/spandx/core/relation.rb', line 6

def io
  @io
end

Instance Method Details

#eachObject



13
14
15
16
17
# File 'lib/spandx/core/relation.rb', line 13

def each
  size.times do |n|
    yield row(n)
  end
end

#row(number) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/spandx/core/relation.rb', line 23

def row(number)
  offset = number.zero? ? 0 : index.position_for(number)
  return unless offset

  io.seek(offset)
  parse_row(io.gets)
end

#sizeObject



19
20
21
# File 'lib/spandx/core/relation.rb', line 19

def size
  index.size
end