Class: Swm::MoveCommand
- Inherits:
-
Object
- Object
- Swm::MoveCommand
- Defined in:
- lib/swm/commands/move_command.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ MoveCommand
constructor
A new instance of MoveCommand.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ MoveCommand
Returns a new instance of MoveCommand.
27 28 29 |
# File 'lib/swm/commands/move_command.rb', line 27 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/swm/commands/move_command.rb', line 25 def @options end |
Class Method Details
.print_help ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/swm/commands/move_command.rb', line 10 def self.print_help puts <<-EOF Usage: swm move <options> Options: --x: Percentage of free screen width --y: Percentage of free screen height Examples: Center the window swm resize --x 50 --y 50 Move the window to the top-right corner swm resize --x 100 --y 0 EOF end |
.run(options) ⇒ Object
6 7 8 |
# File 'lib/swm/commands/move_command.rb', line 6 def self.run() new().run end |
Instance Method Details
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/swm/commands/move_command.rb', line 31 def run x_percent = [:x] y_percent = [:y] screen_dimensions = Screen.dimensions window = Swm::Window.current x = ((screen_dimensions[0] - window.width) * x_percent / 100.0).to_i y = ((screen_dimensions[1] - window.height) * y_percent / 100.0).to_i window.move x, y end |