Class: ProconBypassMan::CompressArray::CompressibleValue
- Inherits:
-
Object
- Object
- ProconBypassMan::CompressArray::CompressibleValue
- Defined in:
- lib/procon_bypass_man/support/compress_array.rb
Instance Method Summary collapse
- #compress? ⇒ Boolean
-
#initialize(prev, current) ⇒ CompressibleValue
constructor
A new instance of CompressibleValue.
- #to_s_with_mark ⇒ String
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
12 13 14 |
# File 'lib/procon_bypass_man/support/compress_array.rb', line 12 def compress? @prev.include?(@current) end |
#to_s_with_mark ⇒ 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 |