-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapter.rb~
43 lines (37 loc) · 942 Bytes
/
adapter.rb~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'strscan'
class Adapter
def initialize( row )
@row = row
end
def method_missing( sym, *args )
name = sym.to_s.sub(/=$/, '')
super unless @row.key?( name )
if /=$/ =~ sym.to_s
return @row[ name ] = args[0]
else
return @row[ name ]
end
end
end
ad = Adapter::new( 'firstname' => 'Roger',
'lastname' => 'Pollack',
'nick' => '(unknown)' )
#p "%s, %s: %s" % [ ad.lastname, ad.firstname, ad.nick ]
a = IO.readlines("cs7204-gw-confg")
a.each_index {|index|
scan = StringScanner.new(a[index])
if scan.scan(/interface Ethernet3\/4/) == "interface Ethernet3/4"
p a[index]
index +=1
scan = StringScanner.new(a[index])
until scan.scan(/interface/) == "interface"
p index
p a[index]
index +=1
scan = StringScanner.new(a[index])
end
end
# if line.include? "interface" then
# p line
#end */
}