Module: Swift::Playground::Util::SourceIO
Instance Method Summary collapse
Instance Method Details
#derived_filename(source) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/swift/playground/util/source_io.rb', line 16 def derived_filename(source) if source.respond_to?(:basename) source.basename.to_s elsif source.respond_to?(:path) File.basename(source.path) end end |
#source_as_io(source) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/swift/playground/util/source_io.rb', line 5 def source_as_io(source) # Return path_or_content if it is an IO-like object return source if source.respond_to?(:read) unless source.is_a?(String) raise "You must provide either a String or an IO object when constructing a #{self.class.name}." end StringIO.new(source) end |