Class: IPAddress::Rle
- Inherits:
-
Object
- Object
- IPAddress::Rle
- Defined in:
- lib/ipaddress/rle.rb
Instance Attribute Summary collapse
-
#cnt ⇒ Object
Returns the value of attribute cnt.
-
#max ⇒ Object
Returns the value of attribute max.
-
#part ⇒ Object
Returns the value of attribute part.
-
#pos ⇒ Object
Returns the value of attribute pos.
Class Method Summary collapse
Instance Method Summary collapse
- #eq(other) ⇒ Object
-
#initialize(obj) ⇒ Rle
constructor
A new instance of Rle.
- #ne(other) ⇒ Object
- #toString ⇒ Object
Constructor Details
#initialize(obj) ⇒ Rle
Returns a new instance of Rle.
52 53 54 55 56 57 |
# File 'lib/ipaddress/rle.rb', line 52 def initialize(obj) @part = obj[:part] @pos = obj[:pos] @cnt = obj[:cnt] @max = obj[:max] end |
Instance Attribute Details
#cnt ⇒ Object
Returns the value of attribute cnt.
50 51 52 |
# File 'lib/ipaddress/rle.rb', line 50 def cnt @cnt end |
#max ⇒ Object
Returns the value of attribute max.
50 51 52 |
# File 'lib/ipaddress/rle.rb', line 50 def max @max end |
#part ⇒ Object
Returns the value of attribute part.
50 51 52 |
# File 'lib/ipaddress/rle.rb', line 50 def part @part end |
#pos ⇒ Object
Returns the value of attribute pos.
50 51 52 |
# File 'lib/ipaddress/rle.rb', line 50 def pos @pos end |
Class Method Details
.code(parts) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ipaddress/rle.rb', line 72 def self.code(parts) last = Last.new() # println!("code") parts.length.times do |i| part = parts[i] # console.log(`part:${part}`) if (last.val && last.val.part == part) last.val.cnt += 1 else last.handle_last() last.val = Rle.new({ part: part, pos: 0, cnt: 1, max: true }) end end last.handle_last() return last.ret end |
Instance Method Details
#eq(other) ⇒ Object
63 64 65 66 |
# File 'lib/ipaddress/rle.rb', line 63 def eq(other) return @part == other.part && @pos == other.pos && @cnt == other.cnt && @max == other.max end |
#ne(other) ⇒ Object
68 69 70 |
# File 'lib/ipaddress/rle.rb', line 68 def ne(other) return !eq(other) end |
#toString ⇒ Object
59 60 61 |
# File 'lib/ipaddress/rle.rb', line 59 def toString() return "<Rle@part:#{@part},pos:#{@pos},cnt:#{@cnt},max:#{@max}>" end |