Method: NETSNMP::Client#initialize
- Defined in:
- lib/netsnmp/client.rb
#initialize(version: nil, **options) {|client| ... } ⇒ Client
Returns a new instance of Client.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/netsnmp/client.rb', line 26 def initialize(version: nil, **) version = case version when Integer then version # assume the use know what he's doing when /v?1/ then 0 when /v?2c?/ then 1 when /v?3/ then 3 else 3 # rubocop:disable Lint/DuplicateBranch end @retries = .fetch(:retries, RETRIES).to_i @session ||= version == 3 ? V3Session.new(**) : Session.new(version: version, **) return unless block_given? begin yield self ensure close end end |