A
A
Alexander Petrov2016-03-24 01:01:18
Ruby on Rails
Alexander Petrov, 2016-03-24 01:01:18

How to remove spaces from a string in Ruby?

I understand that the question is stupid, but for some reason I could not find an answer to it. or poorly searched (
In general, the task is simple. There is a simple css code:

div{
  width:100px;
  height:50px; 
  background:tomato;
}

How to remove all spaces and line breaks from it. In general, to make a solid code in one line?
The code lies in the database and is displayed in a variable.
You need to do it in ruby!

Answer the question

In order to leave comments, you need to log in

5 answer(s)
V
Vayladion Gognazdiak, 2016-03-24
@Mirkom63

.gsub(/\r\n/,'').gsub(' ','')

K
keslo, 2015-01-30
@keslo

Sori, but at first it suggests itself: what for do such broken backgrounds do?

A
Azim Kurt, 2015-01-30
@Symphony

1. Image
2. SVG
3. Canvas
4. div+ccs3 transform skew

E
Eugene Zhadko, 2015-01-30
@Jeka778

You draw whatever image you want in photoshop, then you set the background for the desired block: url(img.png) + absolute positioning, if required.
You can of course in another way, but you do not need it.
Check out the source code on that site...

A
Alexander Tsymbal, 2015-01-30
@AlexanderTsymbal

1. Image
2. SVG

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question