Module: TerminalImage
- Defined in:
- lib/terminal_image.rb,
lib/terminal_image/version.rb
Defined Under Namespace
Classes: UnsupportedTerminal
Constant Summary
collapse
- VERSION =
'0.3.0'
Class Method Summary
collapse
Class Method Details
.encode(file) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/terminal_image.rb', line 30
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
|
.encode_url(url) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/terminal_image.rb', line 23
def encode_url(url)
tempfile = Tempfile.create
tempfile.binmode
URI.open(url) { |o| tempfile.write o.read }
TerminalImage.encode(tempfile)
end
|
.show(file) ⇒ Object
19
20
21
|
# File 'lib/terminal_image.rb', line 19
def show(file)
puts encode(file)
end
|
.show_url(url) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/terminal_image.rb', line 12
def show_url(url)
tempfile = Tempfile.create
tempfile.binmode
URI.open(url) { |o| tempfile.write o.read }
TerminalImage.show(tempfile)
end
|