Class: H8::Command::Stream

Inherits:
Object show all
Defined in:
lib/h8/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, mode, block = nil) ⇒ Stream

Returns a new instance of Stream.



98
99
100
101
102
103
104
# File 'lib/h8/command.rb', line 98

def initialize name, mode, block=nil
  @file = open(name, mode)
  if block
    block.call self
    @file.close
  end
end

Instance Method Details

#read(count = nil) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/h8/command.rb', line 106

def read(count=nil)
  if count
    @file.read(count)
  else
    @file.read
  end
end