diff --git a/lib/crass/parser.rb b/lib/crass/parser.rb index 3447750..86f06ed 100644 --- a/lib/crass/parser.rb +++ b/lib/crass/parser.rb @@ -73,7 +73,7 @@ def self.parse_stylesheet(input, options = {}) # def self.stringify(nodes, options = {}) nodes = [nodes] unless nodes.is_a?(Array) - string = '' + string = String.new nodes.each do |node| next if node.nil? @@ -614,7 +614,7 @@ def parse_rule(input = @tokens) # Returns the unescaped value of a selector name or property declaration. def parse_value(nodes) nodes = [nodes] unless nodes.is_a?(Array) - string = '' + string = String.new nodes.each do |node| case node[:node] diff --git a/lib/crass/tokenizer.rb b/lib/crass/tokenizer.rb index 06484ef..982515d 100644 --- a/lib/crass/tokenizer.rb +++ b/lib/crass/tokenizer.rb @@ -273,7 +273,7 @@ def consume # # 4.3.15. http://dev.w3.org/csswg/css-syntax/#consume-the-remnants-of-a-bad-url def consume_bad_url - text = '' + text = String.new until @s.eos? if valid_escape? @@ -373,7 +373,7 @@ def consume_ident # # 4.3.12. http://dev.w3.org/csswg/css-syntax/#consume-a-name def consume_name - result = '' + result = String.new until @s.eos? if match = @s.scan(RE_NAME) @@ -405,7 +405,7 @@ def consume_name # # 4.3.13. http://dev.w3.org/csswg/css-syntax/#consume-a-number def consume_number - repr = '' + repr = String.new type = :integer repr << @s.consume if @s.peek =~ RE_NUMBER_SIGN @@ -459,7 +459,7 @@ def consume_numeric # 4.3.5. http://dev.w3.org/csswg/css-syntax/#consume-a-string-token def consume_string(ending = nil) ending = @s.current if ending.nil? - value = '' + value = String.new until @s.eos? case char = @s.consume @@ -499,7 +499,7 @@ def consume_string(ending = nil) # # 4.3.7. http://dev.w3.org/csswg/css-syntax/#consume-a-unicode-range-token def consume_unicode_range - value = @s.scan(RE_HEX) || '' + value = @s.scan(RE_HEX) || String.new while value.length < 6 break unless @s.peek == '?' @@ -531,7 +531,7 @@ def consume_unicode_range # # 4.3.6. http://dev.w3.org/csswg/css-syntax/#consume-a-url-token def consume_url - value = '' + value = String.new @s.scan(RE_WHITESPACE)