Class: Cejo::Ops::Screenshot
- Inherits:
-
Object
- Object
- Cejo::Ops::Screenshot
- Defined in:
- lib/cejo/ops/screenshot.rb
Overview
Take a shot of the marvelous screen
Constant Summary collapse
- SCREENSHOT_FORMAT =
'png'
- FOLDER =
Pathname.new(Dir.home).join('Pictures')
- CURRENT_TIME =
Time.new.strftime '%d-%m-%y-%I-%M'
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#utils ⇒ Object
readonly
Returns the value of attribute utils.
Instance Method Summary collapse
- #final_command ⇒ Object
- #flameshot ⇒ Object
-
#initialize(utils, mode) ⇒ Screenshot
constructor
A new instance of Screenshot.
- #maim ⇒ Object
- #run ⇒ Object
- #screenshot_name ⇒ Object
- #scrot ⇒ Object
- #shotter ⇒ Object
- #shotters ⇒ Object
- #shotters_available ⇒ Object
Constructor Details
#initialize(utils, mode) ⇒ Screenshot
Returns a new instance of Screenshot.
13 14 15 16 |
# File 'lib/cejo/ops/screenshot.rb', line 13 def initialize(utils, mode) @utils = utils @mode = mode.to_sym if mode end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
11 12 13 |
# File 'lib/cejo/ops/screenshot.rb', line 11 def mode @mode end |
#utils ⇒ Object (readonly)
Returns the value of attribute utils.
11 12 13 |
# File 'lib/cejo/ops/screenshot.rb', line 11 def utils @utils end |
Instance Method Details
#final_command ⇒ Object
63 64 65 |
# File 'lib/cejo/ops/screenshot.rb', line 63 def final_command "#{shotter[:bin]} #{shotter[mode]} #{shotter[:folder]}" end |
#flameshot ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/cejo/ops/screenshot.rb', line 41 def flameshot { bin: 'flameshot', full: 'full -p', partial: 'gui -p', folder: FOLDER.to_path } end |
#maim ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/cejo/ops/screenshot.rb', line 50 def maim { bin: 'maim', full: '', partial: '--select', folder: FOLDER.join(screenshot_name) } end |
#run ⇒ Object
67 68 69 |
# File 'lib/cejo/ops/screenshot.rb', line 67 def run system final_command end |
#screenshot_name ⇒ Object
59 60 61 |
# File 'lib/cejo/ops/screenshot.rb', line 59 def screenshot_name "screenshot-#{CURRENT_TIME}.#{SCREENSHOT_FORMAT}" end |
#scrot ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/cejo/ops/screenshot.rb', line 32 def scrot { bin: 'scrot', full: '--focused --silent', partial: '--select --silent', folder: FOLDER.join(screenshot_name) } end |
#shotter ⇒ Object
28 29 30 |
# File 'lib/cejo/ops/screenshot.rb', line 28 def shotter shotters_available.first end |
#shotters ⇒ Object
18 19 20 |
# File 'lib/cejo/ops/screenshot.rb', line 18 def shotters [flameshot, scrot, maim] end |
#shotters_available ⇒ Object
22 23 24 25 26 |
# File 'lib/cejo/ops/screenshot.rb', line 22 def shotters_available shotters.find_all do |shotter| shotter[:bin] if utils.which? shotter[:bin] end end |