Class: Cane::File
- Inherits:
-
Object
- Object
- Cane::File
- Defined in:
- lib/cane/file.rb
Overview
An interface for interacting with files that ensures encoding is handled in a consistent manner.
Class Method Summary collapse
Class Method Details
.contents(path) ⇒ Object
13 14 15 |
# File 'lib/cane/file.rb', line 13 def contents(path) open(path).read end |
.exists?(path) ⇒ Boolean
21 22 23 |
# File 'lib/cane/file.rb', line 21 def exists?(path) ::File.exists?(path) end |
.iterator(path) ⇒ Object
9 10 11 |
# File 'lib/cane/file.rb', line 9 def iterator(path) EncodingAwareIterator.new(open(path).each_line) end |
.open(path) ⇒ Object
17 18 19 |
# File 'lib/cane/file.rb', line 17 def open(path) ::File.open(path, 'r:utf-8') end |