Class: Airplay::CLI::ImageViewer
- Inherits:
-
Object
- Object
- Airplay::CLI::ImageViewer
- Defined in:
- lib/airplay/cli/image_viewer.rb
Instance Attribute Summary collapse
-
#devices ⇒ Object
readonly
Returns the value of attribute devices.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(devices, options = {}) ⇒ ImageViewer
constructor
A new instance of ImageViewer.
- #interactive(files) ⇒ Object
- #slideshow(files) ⇒ Object
- #view(file, transition = "SlideLeft") ⇒ Object
Constructor Details
#initialize(devices, options = {}) ⇒ ImageViewer
Returns a new instance of ImageViewer.
6 7 8 9 |
# File 'lib/airplay/cli/image_viewer.rb', line 6 def initialize(devices, = {}) @devices = Array(devices) @options = end |
Instance Attribute Details
#devices ⇒ Object (readonly)
Returns the value of attribute devices.
4 5 6 |
# File 'lib/airplay/cli/image_viewer.rb', line 4 def devices @devices end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/airplay/cli/image_viewer.rb', line 4 def @options end |
Instance Method Details
#interactive(files) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/airplay/cli/image_viewer.rb', line 26 def interactive(files) numbers = Array(0...files.count) transition = "None" i = 0 loop do view(files[i], transition) case read_char when "\e[C" # Right Arrow i = i + 1 > numbers.count - 1 ? 0 : i + 1 transition = "SlideLeft" when "\e[D" # Left Arrow i = i - 1 < 0 ? numbers.count - 1 : i - 1 transition = "SlideRight" else break end end end |
#slideshow(files) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/airplay/cli/image_viewer.rb', line 18 def (files) puts "Autoplay every #{[:wait]}" files.each do |file| view(file) sleep [:wait] end end |
#view(file, transition = "SlideLeft") ⇒ Object
11 12 13 14 15 16 |
# File 'lib/airplay/cli/image_viewer.rb', line 11 def view(file, transition = "SlideLeft") puts "Showing #{file}" devices.each do |device| device.view(file, transition: transition) end end |