Class: SSH::Allow::Command
- Inherits:
-
Object
- Object
- SSH::Allow::Command
- Defined in:
- lib/ssh/allow/command.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #allowed?(rules) ⇒ Boolean
-
#initialize(cmd) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(cmd) ⇒ Command
Returns a new instance of Command.
11 12 13 14 15 16 |
# File 'lib/ssh/allow/command.rb', line 11 def initialize(cmd) @cmd = cmd.to_s @name = parsed.name.text_value @options = parsed.option_list @arguments = parsed.argument_list end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
9 10 11 |
# File 'lib/ssh/allow/command.rb', line 9 def arguments @arguments end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/ssh/allow/command.rb', line 9 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/ssh/allow/command.rb', line 9 def @options end |
Instance Method Details
#allowed?(rules) ⇒ Boolean
26 27 28 29 30 31 32 33 |
# File 'lib/ssh/allow/command.rb', line 26 def allowed?(rules) match, allow = false, false rules.each do |rule| match, allow = rule.match?(self) break if match end allow end |
#run ⇒ Object
22 23 24 |
# File 'lib/ssh/allow/command.rb', line 22 def run system(@cmd) end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/ssh/allow/command.rb', line 18 def to_s @cmd end |