Class: Spandx::Core::Relation
- Inherits:
-
Object
- Object
- Spandx::Core::Relation
- Defined in:
- lib/spandx/core/relation.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(io, index) ⇒ Relation
constructor
A new instance of Relation.
- #row(number) ⇒ Object
- #size ⇒ Object
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
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/spandx/core/relation.rb', line 6 def index @index end |
#io ⇒ Object (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
#each ⇒ Object
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 |
#size ⇒ Object
19 20 21 |
# File 'lib/spandx/core/relation.rb', line 19 def size index.size end |