Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.