Class: Command::Log::Tail
- Inherits:
-
Object
- Object
- Command::Log::Tail
- Defined in:
- lib/command/log/tail.rb
Overview
Constant Summary collapse
- CHUNK_SIZE =
1024 * 16
Instance Attribute Summary collapse
-
#num ⇒ Object
Returns the value of attribute num.
-
#path ⇒ Object
Returns the value of attribute path.
-
#stream_io ⇒ Object
Returns the value of attribute stream_io.
Instance Method Summary collapse
- #display ⇒ Object
-
#initialize(path, num) ⇒ Tail
constructor
A new instance of Tail.
- #stream ⇒ Object
Constructor Details
#initialize(path, num) ⇒ Tail
Returns a new instance of Tail.
15 16 17 18 19 |
# File 'lib/command/log/tail.rb', line 15 def initialize(path, num) self.path = path self.num = num raise unless num.to_i > 0 end |
Instance Attribute Details
#num ⇒ Object
Returns the value of attribute num.
13 14 15 |
# File 'lib/command/log/tail.rb', line 13 def num @num end |
#path ⇒ Object
Returns the value of attribute path.
13 14 15 |
# File 'lib/command/log/tail.rb', line 13 def path @path end |
#stream_io ⇒ Object
Returns the value of attribute stream_io.
13 14 15 |
# File 'lib/command/log/tail.rb', line 13 def stream_io @stream_io end |
Instance Method Details
#display ⇒ Object
30 31 32 33 34 |
# File 'lib/command/log/tail.rb', line 30 def display execute do |file| stream_io.puts file.read end end |
#stream ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/command/log/tail.rb', line 21 def stream execute do |file| loop do stream_io.print file.read sleep 0.1 end end end |