Class: Hermeneutics::MBox::Region
- Inherits:
-
Object
- Object
- Hermeneutics::MBox::Region
- Defined in:
- lib/hermeneutics/boxes.rb
Overview
:stopdoc:
Class Method Summary collapse
Instance Method Summary collapse
- #each_line ⇒ Object (also: #eat_lines)
-
#initialize(file, start, stop) ⇒ Region
constructor
A new instance of Region.
- #read(n = nil) ⇒ Object
- #rewind ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file, start, stop) ⇒ Region
Returns a new instance of Region.
131 132 133 134 |
# File 'lib/hermeneutics/boxes.rb', line 131 def initialize file, start, stop @file, @start, @stop = file, start, stop rewind end |
Class Method Details
.open(file, start, stop) ⇒ Object
121 122 123 124 125 126 127 128 129 |
# File 'lib/hermeneutics/boxes.rb', line 121 def open file, start, stop t = file.tell begin i = new file, start, stop yield i ensure file.seek t end end |
Instance Method Details
#each_line ⇒ Object Also known as: eat_lines
145 146 147 148 149 150 |
# File 'lib/hermeneutics/boxes.rb', line 145 def each_line @file.each_line { |l| break if @file.tell > @stop yield l } end |
#read(n = nil) ⇒ Object
136 137 138 139 140 |
# File 'lib/hermeneutics/boxes.rb', line 136 def read n = nil m = @stop - @file.tell n = m if not n or n > m @file.read n end |
#rewind ⇒ Object
135 |
# File 'lib/hermeneutics/boxes.rb', line 135 def rewind ; @file.seek @start ; end |
#to_s ⇒ Object
141 142 143 144 |
# File 'lib/hermeneutics/boxes.rb', line 141 def to_s rewind read end |