Class: OsCtld::History::Reader
- Inherits:
-
Object
- Object
- OsCtld::History::Reader
- Includes:
- Enumerable
- Defined in:
- lib/osctld/history.rb
Instance Method Summary collapse
- #close ⇒ Object
- #each ⇒ Object
- #eof? ⇒ Boolean
-
#initialize(path) ⇒ Reader
constructor
A new instance of Reader.
- #parse ⇒ Object protected
- #read ⇒ Object
Constructor Details
#initialize(path) ⇒ Reader
Returns a new instance of Reader.
7 8 9 |
# File 'lib/osctld/history.rb', line 7 def initialize(path) @f = File.open(path, 'r') end |
Instance Method Details
#close ⇒ Object
11 12 13 |
# File 'lib/osctld/history.rb', line 11 def close @f.close end |
#each ⇒ Object
15 16 17 18 19 |
# File 'lib/osctld/history.rb', line 15 def each yield(parse) until @f.eof? rescue EOFError end |
#eof? ⇒ Boolean
23 24 25 |
# File 'lib/osctld/history.rb', line 23 def eof? @f.eof? end |
#parse ⇒ Object (protected)
32 33 34 |
# File 'lib/osctld/history.rb', line 32 def parse JSON.parse(@f.readline, symbolize_names: true) end |
#read ⇒ Object
27 28 29 |
# File 'lib/osctld/history.rb', line 27 def read parse end |