Class: Commutateurs::HP
Instance Method Summary collapse
- #clean(arg) ⇒ Object
- #configuration ⇒ Object
- #connect ⇒ Object
- #disconnect ⇒ Object
- #enable ⇒ Object
- #execute(arg) ⇒ Object
-
#initialize(host, credentials, verbose = false) ⇒ HP
constructor
A new instance of HP.
- #save ⇒ Object
Constructor Details
#initialize(host, credentials, verbose = false) ⇒ HP
Returns a new instance of HP.
27 28 29 30 31 |
# File 'lib/commutateurs/device.rb', line 27 def initialize(host, credentials, verbose = false) super @transport.default_prompt = /(Press any key to continue|# )/ @transport.debug = Proc.new { |line| $stderr.print(clean(line)) } end |
Instance Method Details
#clean(arg) ⇒ Object
60 61 62 63 64 |
# File 'lib/commutateurs/device.rb', line 60 def clean(arg) cleaned = "" (arg || "").each_byte { |x| cleaned << x unless x > 127 } cleaned end |
#configuration ⇒ Object
43 44 45 |
# File 'lib/commutateurs/device.rb', line 43 def configuration execute('write term') end |
#connect ⇒ Object
33 34 35 36 37 |
# File 'lib/commutateurs/device.rb', line 33 def connect @transport.connect @transport.command("\n") @transport.command("terminal length 1000") end |
#disconnect ⇒ Object
51 52 53 54 |
# File 'lib/commutateurs/device.rb', line 51 def disconnect @transport.send 'exit' @transport.close end |
#enable ⇒ Object
39 40 41 |
# File 'lib/commutateurs/device.rb', line 39 def enable end |
#execute(arg) ⇒ Object
56 57 58 |
# File 'lib/commutateurs/device.rb', line 56 def execute(arg) clean(super(arg)) end |
#save ⇒ Object
47 48 49 |
# File 'lib/commutateurs/device.rb', line 47 def save raise "Not implemented yet" end |