Module: IMW::Schemes::Remote::RemoteFile
- Defined in:
- lib/imw/schemes/remote.rb
Instance Method Summary collapse
-
#io ⇒ StringIO
Return the IO object for this remote file.
-
#load {|String| ... } ⇒ Array
Return the lines of this remote file.
-
#map {|String| ... } ⇒ Object
Map over the lines in this remote file.
-
#read ⇒ String
Read the contents of this remote file.
Instance Method Details
#io ⇒ StringIO
Return the IO object for this remote file.
The mode of this resource is ignored.
67 68 69 70 |
# File 'lib/imw/schemes/remote.rb', line 67 def io require 'open-uri' @io ||= open(uri.to_s) # ignore mode end |
#load {|String| ... } ⇒ Array
Return the lines of this remote file.
If passed a block then yield each line to the block.
85 86 87 88 89 90 91 92 93 |
# File 'lib/imw/schemes/remote.rb', line 85 def load &block if block_given? io.each do |line| yield line end else read.split("\n") end end |
#map {|String| ... } ⇒ Object
Map over the lines in this remote file.
98 99 100 |
# File 'lib/imw/schemes/remote.rb', line 98 def map &block io.map(&block) end |
#read ⇒ String
Read the contents of this remote file.
75 76 77 |
# File 'lib/imw/schemes/remote.rb', line 75 def read io.read end |