Class: Rubino::Compression::CompressionResult

Inherits:
Data
  • Object
show all
Defined in:
lib/rubino/compression/compression_result.rb

Overview

Immutable result of one compression attempt. ‘applied?` is the single gate the caller checks: when false, `text` is meaningless (use the original) and `saved_tokens_est` is zeroed. When true, `text` is the skeleton and `saved_tokens_est` is the estimated saving. `strategy` is :skeleton (or the per-type tag) when applied, otherwise the no-op REASON (:not_full_file/ :not_code/:too_small/:parse_error/:insufficient_saving) for measurement events.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#appliedObject (readonly)

Returns the value of attribute applied

Returns:

  • (Object)

    the current value of applied



22
23
24
# File 'lib/rubino/compression/compression_result.rb', line 22

def applied
  @applied
end

#saved_tokens_estObject (readonly)

Returns the value of attribute saved_tokens_est

Returns:

  • (Object)

    the current value of saved_tokens_est



22
23
24
# File 'lib/rubino/compression/compression_result.rb', line 22

def saved_tokens_est
  @saved_tokens_est
end

#strategyObject (readonly)

Returns the value of attribute strategy

Returns:

  • (Object)

    the current value of strategy



22
23
24
# File 'lib/rubino/compression/compression_result.rb', line 22

def strategy
  @strategy
end

#textObject (readonly)

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



22
23
24
# File 'lib/rubino/compression/compression_result.rb', line 22

def text
  @text
end

Class Method Details

.noop(strategy:) ⇒ Object

The no-op result: nothing was compressed, the caller sends the original.



30
31
32
# File 'lib/rubino/compression/compression_result.rb', line 30

def self.noop(strategy:)
  new(text: nil, saved_tokens_est: 0, strategy: strategy, applied: false)
end

Instance Method Details

#applied?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/rubino/compression/compression_result.rb', line 25

def applied?
  applied
end