Module: TerminalImage
- Defined in:
- lib/terminal_image.rb,
lib/terminal_image/version.rb
Defined Under Namespace
Classes: UnsupportedTerminal
Constant Summary
collapse
- VERSION =
"0.2.0"
Class Method Summary
collapse
Class Method Details
.encode(file) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/terminal_image.rb', line 21
def encode(file)
if ENV['TERM_PROGRAM'] == 'iTerm.app'
encode_for_iterm2(file)
elsif which 'img2sixel'
encode_for_libsixel(file)
else
puts 'Use iTerm2 or install libsixel according to https://github.com/saitoha/libsixel#install'
raise UnsupportedTerminal, 'Unsupported terminal'
end
end
|
.show(file) ⇒ Object
17
18
19
|
# File 'lib/terminal_image.rb', line 17
def show(file)
puts encode(file)
end
|
.show_url(url) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/terminal_image.rb', line 10
def show_url(url)
tempfile = Tempfile.create
tempfile.binmode
URI.open(url) { |o| tempfile.write o.read }
TerminalImage.show(tempfile)
end
|