Class: ProconBypassMan::CompressArray::CompressibleValue

Inherits:
Object
  • Object
show all
Defined in:
lib/procon_bypass_man/support/compress_array.rb

Instance Method Summary collapse

Constructor Details

#initialize(prev, current) ⇒ CompressibleValue

Returns a new instance of CompressibleValue.



6
7
8
9
# File 'lib/procon_bypass_man/support/compress_array.rb', line 6

def initialize(prev, current)
  @prev = prev
  @current = current
end

Instance Method Details

#compress?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/procon_bypass_man/support/compress_array.rb', line 12

def compress?
  @prev.include?(@current)
end

#to_s_with_markString

Returns:

  • (String)


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/procon_bypass_man/support/compress_array.rb', line 17

def to_s_with_mark
  if /^(.+) \* (\d+)/ =~ @prev
    value = $1
    count = $2
    return "#{value} * #{count.to_i + 1}"
  end
  if /^(.+)/ =~ @prev
    value = $1
    return "#{value} * 1"
  end
end