Skip to content

Instantly share code, notes, and snippets.

@zaiste
Created July 19, 2014 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zaiste/2cc43abd00d459cef52c to your computer and use it in GitHub Desktop.
Save zaiste/2cc43abd00d459cef52c to your computer and use it in GitHub Desktop.
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