declare instance variables explicitly

This commit is contained in:
dcorrigan 2017-05-05 09:33:04 -04:00
parent 5362469484
commit bb4e64a455

View File

@ -190,6 +190,8 @@ class FastImage
@property = @options[:type_only] ? :type : :size @property = @options[:type_only] ? :type : :size
@type, @state = nil
if uri.respond_to?(:read) if uri.respond_to?(:read)
fetch_using_read(uri) fetch_using_read(uri)
elsif uri.start_with?('data:') elsif uri.start_with?('data:')
@ -431,7 +433,7 @@ class FastImage
@strpos = 0 @strpos = 0
end end
result = @str[@strpos..(@strpos + n - 1)] @str[@strpos..(@strpos + n - 1)]
end end
def read(n) def read(n)
@ -518,6 +520,7 @@ class FastImage
end end
def parse_size_for_jpeg def parse_size_for_jpeg
exif = nil
loop do loop do
@state = case @state @state = case @state
when nil when nil
@ -533,7 +536,7 @@ class FastImage
io = StringIO.new(data) io = StringIO.new(data)
if io.read(4) == "Exif" if io.read(4) == "Exif"
io.read(2) io.read(2)
@exif = Exif.new(IOStream.new(io)) rescue nil exif = Exif.new(IOStream.new(io)) rescue nil
end end
:started :started
when 0xe0..0xef when 0xe0..0xef
@ -553,8 +556,8 @@ class FastImage
@stream.skip(3) @stream.skip(3)
height = @stream.read_int height = @stream.read_int
width = @stream.read_int width = @stream.read_int
width, height = height, width if @exif && @exif.rotated? width, height = height, width if exif && exif.rotated?
return [width, height, @exif ? @exif.orientation : 1] return [width, height, exif ? exif.orientation : 1]
end end
end end
end end
@ -575,7 +578,7 @@ class FastImage
def parse_size_for_webp def parse_size_for_webp
vp8 = @stream.read(16)[12..15] vp8 = @stream.read(16)[12..15]
len = @stream.read(4).unpack("V") _len = @stream.read(4).unpack("V")
case vp8 case vp8
when "VP8 " when "VP8 "
parse_size_vp8 parse_size_vp8
@ -617,6 +620,7 @@ class FastImage
def initialize(stream) def initialize(stream)
@stream = stream @stream = stream
@width, @height, @orientation = nil
parse_exif parse_exif
end end
@ -696,6 +700,7 @@ class FastImage
class Svg # :nodoc: class Svg # :nodoc:
def initialize(stream) def initialize(stream)
@stream = stream @stream = stream
@width, @height, @ratio, @viewbox_width, @viewbox_height = nil
parse_svg parse_svg
end end