Module: OpenAsText

Defined in:
lib/open_as_text.rb,
lib/open_as_text/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Instance Method Summary collapse

Instance Method Details

#open_as_text(object = nil) ⇒ Object Also known as: ot



7
8
9
10
11
12
13
14
15
# File 'lib/open_as_text.rb', line 7

def open_as_text(object = nil)
  object = object || self
  tempfile = Tempfile.open("#{object.class.name}-#{object.object_id}-")
  tempfile.write(object.pretty_inspect)
  tempfile.flush
  puts "opening... #{tempfile.path}"
  Launchy.open(tempfile.path)
  object
end