mirror of
				https://github.com/sdsykes/fastimage.git
				synced 2025-11-04 00:01:39 -05:00 
			
		
		
		
	Add read_string_int method to StreamUtil
This commit is contained in:
		
							parent
							
								
									39d9dfbf05
								
							
						
					
					
						commit
						035ebe3ed6
					
				@ -343,6 +343,14 @@ class FastImage
 | 
			
		||||
    def read_int
 | 
			
		||||
      read(2).unpack('n')[0]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def read_string_int
 | 
			
		||||
      value = []
 | 
			
		||||
      while read(1) =~ /(\d)/
 | 
			
		||||
        value << $1
 | 
			
		||||
      end
 | 
			
		||||
      value.join.to_i
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  class FiberStream # :nodoc:
 | 
			
		||||
@ -625,10 +633,12 @@ class FastImage
 | 
			
		||||
        case char
 | 
			
		||||
        when "="
 | 
			
		||||
          if attr_name.join =~ /width/i
 | 
			
		||||
            @width = attr_value.to_i
 | 
			
		||||
            @stream.read(1)
 | 
			
		||||
            @width = @stream.read_string_int
 | 
			
		||||
            return if @height
 | 
			
		||||
          elsif attr_name.join =~ /height/i
 | 
			
		||||
            @height = attr_value.to_i
 | 
			
		||||
            @stream.read(1)
 | 
			
		||||
            @height = @stream.read_string_int
 | 
			
		||||
            return if @width
 | 
			
		||||
          elsif attr_name.join =~ /viewbox/i
 | 
			
		||||
            values = attr_value.split(/\s/)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user