lib/io_streams/stream.rb in iostreams-1.1.0 vs lib/io_streams/stream.rb in iostreams-1.1.1
- old
+ new
@@ -2,11 +2,11 @@
class Stream
attr_reader :io_stream
attr_writer :builder
def initialize(io_stream)
- raise(ArgumentError, 'io_stream cannot be nil') if io_stream.nil?
+ raise(ArgumentError, "io_stream cannot be nil") if io_stream.nil?
raise(ArgumentError, "io_stream must not be a string: #{io_stream.inspect}") if io_stream.is_a?(String)
@io_stream = io_stream
@builder = nil
end
@@ -264,11 +264,11 @@
# IOStreams.path("foo.").extension #=> ""
# IOStreams.path("test").extension #=> ""
# IOStreams.path(".profile").extension #=> ""
# IOStreams.path(".profile.sh").extension #=> "sh"
def extension
- extname&.sub(/^\./, '')
+ extname&.sub(/^\./, "")
end
private
def builder
@@ -278,11 +278,11 @@
def stream_reader(&block)
builder.reader(io_stream, &block)
end
def line_reader(embedded_within: nil, **args)
- embedded_within = '"' if embedded_within.nil? && builder.file_name&.include?('.csv')
+ embedded_within = '"' if embedded_within.nil? && builder.file_name&.include?(".csv")
stream_reader { |io| yield IOStreams::Line::Reader.new(io, embedded_within: embedded_within, **args) }
end
# Iterate over a file / stream returning each line as an array, one at a time.
@@ -302,22 +302,22 @@
def stream_writer(&block)
builder.writer(io_stream, &block)
end
def line_writer(**args, &block)
- return block.call(io_stream) if io_stream && io_stream.is_a?(IOStreams::Line::Writer)
+ return block.call(io_stream) if io_stream&.is_a?(IOStreams::Line::Writer)
writer { |io| IOStreams::Line::Writer.stream(io, **args, &block) }
end
def row_writer(delimiter: $/, **args, &block)
- return block.call(io_stream) if io_stream && io_stream.is_a?(IOStreams::Row::Writer)
+ return block.call(io_stream) if io_stream&.is_a?(IOStreams::Row::Writer)
line_writer(delimiter: delimiter) { |io| IOStreams::Row::Writer.stream(io, **args, &block) }
end
def record_writer(delimiter: $/, **args, &block)
- return block.call(io_stream) if io_stream && io_stream.is_a?(IOStreams::Record::Writer)
+ return block.call(io_stream) if io_stream&.is_a?(IOStreams::Record::Writer)
line_writer(delimiter: delimiter) { |io| IOStreams::Record::Writer.stream(io, **args, &block) }
end
end
end