Created
July 19, 2014 09:57
-
-
Save zaiste/2cc43abd00d459cef52c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def unindent | |
gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "") | |
end | |
end | |
def display | |
text = <<-TEXT.unindent | |
Lorem ipsum dolor sit amet, | |
consectetur adipisicing elit, | |
TEXT | |
end | |
Person = Struct.new(:name) | |
if true | |
h = { value1: <<-value1.unindent, value2: <<-value2 } | |
Hello, this is value 1 | |
boo | |
value1 | |
Hello, this is value 2 | |
value2 | |
p1 = Person.new(name: <<-name.unindent) | |
this is test | |
how it works | |
name | |
p2 = Person.new(name: <<-name.unindent | |
this is test | |
how it works | |
name | |
) | |
p3 = Person.new(name: " | |
this is test | |
how it works".unindent) | |
end | |
puts " | |
this is test | |
and this is test again".unindent | |
puts h | |
puts p1 | |
puts p2 | |
puts p3 | |
puts display | |
puts <<-`command` | |
date | |
command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment