Class: Rubko::Asset::FileStream
- Inherits:
-
Object
- Object
- Rubko::Asset::FileStream
- Defined in:
- lib/rubko/asset/fileStream.rb
Instance Method Summary collapse
- #bytesize ⇒ Object
- #each ⇒ Object
-
#initialize(path, chunk = 32) ⇒ FileStream
constructor
A new instance of FileStream.
Constructor Details
#initialize(path, chunk = 32) ⇒ FileStream
Returns a new instance of FileStream.
2 3 4 5 |
# File 'lib/rubko/asset/fileStream.rb', line 2 def initialize(path, chunk = 32) @path = path @chunk = 1024*chunk end |
Instance Method Details
#bytesize ⇒ Object
15 16 17 |
# File 'lib/rubko/asset/fileStream.rb', line 15 def bytesize File.size @path end |
#each ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/rubko/asset/fileStream.rb', line 7 def each File.open(@path, 'rb') { |f| while part = f.read(@chunk) yield part end } end |