Class: R3Status::Blocks::Shell
- Defined in:
- lib/r3status/blocks/shell.rb
Constant Summary
Constants inherited from Base
Base::DEFAULT_COLOR, Base::DEFAULT_FORMAT
Instance Attribute Summary collapse
-
#click_commands ⇒ Object
Returns the value of attribute click_commands.
-
#command ⇒ Object
Returns the value of attribute command.
Attributes inherited from Base
#clicked_block, #colors, #formats, #full_text, #max_length, #name, #text_color
Instance Method Summary collapse
- #clicked(button, x, y) ⇒ Object
-
#initialize(**args, &block) ⇒ Shell
constructor
A new instance of Shell.
- #update ⇒ Object
Methods inherited from Base
#color, #color=, #format, #format=, #state, #terminate, #to_s
Constructor Details
#initialize(**args, &block) ⇒ Shell
Returns a new instance of Shell.
5 6 7 |
# File 'lib/r3status/blocks/shell.rb', line 5 def initialize(**args, &block) super(args, &block) end |
Instance Attribute Details
#click_commands ⇒ Object
Returns the value of attribute click_commands.
3 4 5 |
# File 'lib/r3status/blocks/shell.rb', line 3 def click_commands @click_commands end |
#command ⇒ Object
Returns the value of attribute command.
3 4 5 |
# File 'lib/r3status/blocks/shell.rb', line 3 def command @command end |
Instance Method Details
#clicked(button, x, y) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/r3status/blocks/shell.rb', line 19 def clicked(, x, y) super(, x, y) case click_commands.class when String `#{click_commands}` when Array `#{click_commands[ - 1]}` when Hash `#{click_commands[]}` end end |
#update ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/r3status/blocks/shell.rb', line 9 def update return if command.nil? cmd = `#{command}`.split.map {|str| str.chomp} return if cmd.length == 0 @full_text = cmd[0] @text_color = cmd[1] if cmd.length >= 2 end |