Class: SSH::Allow::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh/allow/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#argumentsObject (readonly)

Returns the value of attribute arguments.



9
10
11
# File 'lib/ssh/allow/command.rb', line 9

def arguments
  @arguments
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/ssh/allow/command.rb', line 9

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/ssh/allow/command.rb', line 9

def options
  @options
end

Instance Method Details

#allowed?(rules) ⇒ Boolean

Returns:

  • (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

#runObject



22
23
24
# File 'lib/ssh/allow/command.rb', line 22

def run
  system(@cmd)
end

#to_sObject



18
19
20
# File 'lib/ssh/allow/command.rb', line 18

def to_s
  @cmd
end