Class: SshDevice::Response
- Inherits:
-
Object
- Object
- SshDevice::Response
- Defined in:
- lib/brocadesan/device.rb
Overview
This class defines the device response and it should not be manipulated directly Only exception is direct usage of query method which returns instance of this class
Instance Attribute Summary collapse
-
#data ⇒ Object
contains output of the command.
-
#errors ⇒ Object
contains errors raised by SSH exec.
-
#parsed ⇒ Object
contains parsed information after the parse method ran.
Instance Method Summary collapse
-
#initialize(prompt) ⇒ Response
constructor
initialization method.
-
#parse ⇒ Object
Parse the current data and stores result to
parsed
. -
#reset ⇒ Object
Resets all parsed data.
Constructor Details
#initialize(prompt) ⇒ Response
initialization method
253 254 255 256 257 258 259 260 |
# File 'lib/brocadesan/device.rb', line 253 def initialize(prompt) # :nodoc: @errors="" @data="" @parsed = { :parsing_position=>nil } @prompt=prompt end |
Instance Attribute Details
#data ⇒ Object
contains output of the command
246 247 248 |
# File 'lib/brocadesan/device.rb', line 246 def data @data end |
#errors ⇒ Object
contains errors raised by SSH exec
248 249 250 |
# File 'lib/brocadesan/device.rb', line 248 def errors @errors end |
#parsed ⇒ Object
contains parsed information after the parse method ran
250 251 252 |
# File 'lib/brocadesan/device.rb', line 250 def parsed @parsed end |
Instance Method Details
#parse ⇒ Object
Parse the current data and stores result to parsed
.
Any class that inherits from this class should override the private parse_line method and store results into parsed
hash
273 274 275 276 277 278 279 280 281 |
# File 'lib/brocadesan/device.rb', line 273 def parse # :nodoc: reset if !@parsed.kind_of? Hash @data.split("\n").each do |line| parse_line line end @parsed[:parsing_position]="end" end |
#reset ⇒ Object
Resets all parsed data
264 265 266 267 268 |
# File 'lib/brocadesan/device.rb', line 264 def reset # :nodoc: @parsed = { :parsing_position=>nil } end |