Class: Swm::ResizeCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/swm/commands/resize_command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ResizeCommand

Returns a new instance of ResizeCommand.



30
31
32
# File 'lib/swm/commands/resize_command.rb', line 30

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



28
29
30
# File 'lib/swm/commands/resize_command.rb', line 28

def options
  @options
end

Class Method Details



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/swm/commands/resize_command.rb', line 10

def self.print_help
  puts <<-EOF
Usage: swm resize <options>
Options:
  --x:      X-coord of top-left corner in percent of screen
  --y:      Y-ccord of top-left corner in percent of screen
  --width:  Width in percent of screen
  --height: Height in percent of screen
  --left:   (Optional) Sets a left margin of the screen
  --right:  (Optional) Sets a right margin of the screen
  --top:    (Optional) Sets a top margin of the screen
  --bottom: (Optional) Sets a bottom margin of the screen
Examples:
  Make window fill 80 percent of screen in each dimension with a 10 percent margin:
swm resize --x 10 --y 10 --width 80 --height 80
  EOF
end

.run(options) ⇒ Object



6
7
8
# File 'lib/swm/commands/resize_command.rb', line 6

def self.run(options)
  new(options).run
end

Instance Method Details

#runObject



34
35
36
37
38
39
# File 'lib/swm/commands/resize_command.rb', line 34

def run
  screen_dimensions = Screen.dimensions
  rect = [0, 0, screen_dimensions[0], screen_dimensions[1]]
  set_offset(rect)
  resize_in_rect(rect)
end