Class: OpenCensus::Trace::TruncatableString
- Inherits:
- 
      Object
      
        - Object
- OpenCensus::Trace::TruncatableString
 
- Defined in:
- lib/opencensus/trace/truncatable_string.rb
Overview
A string that might be shortened to a specified length.
Instance Attribute Summary collapse
- 
  
    
      #truncated_byte_count  ⇒ Integer 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The number of bytes removed from the original string. 
- 
  
    
      #value  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The shortened string. 
Instance Method Summary collapse
- 
  
    
      #initialize(value, truncated_byte_count: 0)  ⇒ TruncatableString 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Create an empty TruncatableString object. 
- 
  
    
      #to_s  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Override the default to_s implementation. 
Constructor Details
#initialize(value, truncated_byte_count: 0) ⇒ TruncatableString
Create an empty TruncatableString object.
| 46 47 48 49 | # File 'lib/opencensus/trace/truncatable_string.rb', line 46 def initialize value, truncated_byte_count: 0 @value = value @truncated_byte_count = truncated_byte_count end | 
Instance Attribute Details
#truncated_byte_count ⇒ Integer (readonly)
The number of bytes removed from the original string. If this value is 0, then the string was not shortened.
| 39 40 41 | # File 'lib/opencensus/trace/truncatable_string.rb', line 39 def truncated_byte_count @truncated_byte_count end | 
#value ⇒ String (readonly)
The shortened string. For example, if the original string was 500 bytes long and the limit of the string was 128 bytes, then this value contains the first 128 bytes of the 500-byte string. Note that truncation always happens on a character boundary, to ensure that a truncated string is still valid UTF-8. Because it may contain multi-byte characters, the size of the truncated string may be less than the truncation limit.
| 31 32 33 | # File 'lib/opencensus/trace/truncatable_string.rb', line 31 def value @value end | 
Instance Method Details
#to_s ⇒ Object
Override the default to_s implementation.
| 56 57 58 | # File 'lib/opencensus/trace/truncatable_string.rb', line 56 def to_s @value end |