Class: IPRange
Constant Summary
Constants included from BasicLogging
BasicLogging::DEBUG, BasicLogging::ERROR, BasicLogging::FATAL, BasicLogging::INFO, BasicLogging::Levels, BasicLogging::UNKNOWN, BasicLogging::WARN
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
-
#vrange ⇒ Object
readonly
Returns the value of attribute vrange.
Attributes included from BasicLogging
Instance Method Summary collapse
-
#in_range?(cip) ⇒ Boolean
check IP in range ?.
-
#initialize(args) ⇒ IPRange
constructor
create an IP-range.
- #irange ⇒ Object
Methods included from BasicLogging
is_muted?, #log, mute, #set_level, #set_target
Constructor Details
#initialize(args) ⇒ IPRange
create an IP-range
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ip_range.rb', line 49 def initialize(args) if args && args.length >= 2 #first IP @first = ip_to_number args[0] #last IP @last = ip_to_number args[1] if @last && @first && ( @last < @first ) error('ERROR! Last IP is smaller than the first (' << @first.to_s << ' - ' << @last.to_s << ')') error('Aborting!') exit false end @vrange = args[0,2] end end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
65 66 67 |
# File 'lib/ip_range.rb', line 65 def first @first end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
65 66 67 |
# File 'lib/ip_range.rb', line 65 def last @last end |
#vrange ⇒ Object (readonly)
Returns the value of attribute vrange.
65 66 67 |
# File 'lib/ip_range.rb', line 65 def vrange @vrange end |
Instance Method Details
#in_range?(cip) ⇒ Boolean
check IP in range ?
40 41 42 |
# File 'lib/ip_range.rb', line 40 def in_range?(cip) (@first..@last) === ip_to_number(cip) end |
#irange ⇒ Object
44 45 46 |
# File 'lib/ip_range.rb', line 44 def irange() [@first, @last] end |