Class: Foobara::CommandConnectors::ShCliConnector::ActionParser::Result
- Inherits:
-
Object
- Object
- Foobara::CommandConnectors::ShCliConnector::ActionParser::Result
- Defined in:
- foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/action_parser.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#argument ⇒ Object
Returns the value of attribute argument.
-
#parsed ⇒ Object
Returns the value of attribute parsed.
-
#remainder ⇒ Object
Returns the value of attribute remainder.
Instance Method Summary collapse
-
#initialize(action = nil) ⇒ Result
constructor
A new instance of Result.
- #validate! ⇒ Object
Constructor Details
#initialize(action = nil) ⇒ Result
Returns a new instance of Result.
9 10 11 12 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/action_parser.rb', line 9 def initialize(action = nil) self.parsed = {} self.action = action end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/action_parser.rb', line 7 def action @action end |
#argument ⇒ Object
Returns the value of attribute argument.
7 8 9 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/action_parser.rb', line 7 def argument @argument end |
#parsed ⇒ Object
Returns the value of attribute parsed.
6 7 8 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/action_parser.rb', line 6 def parsed @parsed end |
#remainder ⇒ Object
Returns the value of attribute remainder.
6 7 8 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/action_parser.rb', line 6 def remainder @remainder end |
Instance Method Details
#validate! ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'foobara-sh-cli-connector-0.0.16/src/sh_cli_connector/action_parser.rb', line 38 def validate! if action.nil? raise ParseError, "Found invalid option #{remainder.first} but was expecting an action like 'run' or 'help'" end if action == "run" unless argument raise ParseError, "Missing command to run" end elsif action == "describe" unless argument raise ParseError, "Missing command or type to describe" end end end |