Class: Scope
- Inherits:
-
Object
- Object
- Scope
- Defined in:
- lib/msdhcpdump/scope.rb
Instance Attribute Summary collapse
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#endrange ⇒ Object
Returns the value of attribute endrange.
-
#exclusions ⇒ Object
Returns the value of attribute exclusions.
-
#mask ⇒ Object
Returns the value of attribute mask.
-
#name ⇒ Object
Returns the value of attribute name.
-
#net ⇒ Object
Returns the value of attribute net.
-
#option ⇒ Object
Returns the value of attribute option.
-
#reservations ⇒ Object
Returns the value of attribute reservations.
-
#reserved ⇒ Object
Returns the value of attribute reserved.
-
#startrange ⇒ Object
Returns the value of attribute startrange.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #addexclusion(range = []) ⇒ Object
- #addreservation(reservation = []) ⇒ Object
- #getreservations ⇒ Object
-
#initialize(matchobj) ⇒ Scope
constructor
A new instance of Scope.
- #listreservations ⇒ Object
- #setstate(value) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(matchobj) ⇒ Scope
Returns a new instance of Scope.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/msdhcpdump/scope.rb', line 4 def initialize(matchobj) scopearray = matchobj.split(' ',3).to_a @net = scopearray[0] @mask = scopearray[1] @name = scopearray[2].match(/([\w+\ ?]+)/i)[1] # TODO Find out how to parse the description out @desc = nil @option = nil @exclusions = Array.new @reserved = Array.new @reservations = Hash.new end |
Instance Attribute Details
#desc ⇒ Object
Returns the value of attribute desc.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def desc @desc end |
#endrange ⇒ Object
Returns the value of attribute endrange.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def endrange @endrange end |
#exclusions ⇒ Object
Returns the value of attribute exclusions.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def exclusions @exclusions end |
#mask ⇒ Object
Returns the value of attribute mask.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def mask @mask end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def name @name end |
#net ⇒ Object
Returns the value of attribute net.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def net @net end |
#option ⇒ Object
Returns the value of attribute option.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def option @option end |
#reservations ⇒ Object
Returns the value of attribute reservations.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def reservations @reservations end |
#reserved ⇒ Object
Returns the value of attribute reserved.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def reserved @reserved end |
#startrange ⇒ Object
Returns the value of attribute startrange.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def startrange @startrange end |
#state ⇒ Object
Returns the value of attribute state.
2 3 4 |
# File 'lib/msdhcpdump/scope.rb', line 2 def state @state end |
Instance Method Details
#active? ⇒ Boolean
23 24 25 |
# File 'lib/msdhcpdump/scope.rb', line 23 def active? return @state.to_i == 1 end |
#addexclusion(range = []) ⇒ Object
20 21 22 |
# File 'lib/msdhcpdump/scope.rb', line 20 def addexclusion(range=[]) @exclusions << Exclusion.new(range) end |
#addreservation(reservation = []) ⇒ Object
47 48 49 50 51 |
# File 'lib/msdhcpdump/scope.rb', line 47 def addreservation(reservation=[]) newreservation = Reservation.new(reservation) @reservations[newreservation.mac] = newreservation end |
#getreservations ⇒ Object
29 30 31 |
# File 'lib/msdhcpdump/scope.rb', line 29 def getreservations @reservations.values end |
#listreservations ⇒ Object
26 27 28 |
# File 'lib/msdhcpdump/scope.rb', line 26 def listreservations @reservations.keys end |
#setstate(value) ⇒ Object
17 18 19 |
# File 'lib/msdhcpdump/scope.rb', line 17 def setstate value @state = value end |
#to_s ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/msdhcpdump/scope.rb', line 32 def to_s p= Array.new p[0] = "Scope Network: #{@net}" p[1] = "Scope Netmask: #{@mask}" p[2] = "Scope Range: #{@startrange} - #{@endrange}" p[3] = "Scope Name: #{@name}" p[4] = "Scope option: #{@option}" p[5] = "Scope desc: #{@desc}" p[6] = "Scope active status: #{state}" p[7] = "Scope IP exclusions: \n#{@exclusions}" p[8] = "Scope current reservations: \n#{getreservations.to_s}" p[9] = "\n" return p end |