Class: Transit::ByteArray

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/transit/transit_types.rb

Overview

Represents a transit byte array extension type.

Instance Attribute Summary

Attributes inherited from Wrapper

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Wrapper

#==, #initialize, #inspect

Constructor Details

This class inherits a constructor from Transit::Wrapper

Class Method Details

.from_base64(data) ⇒ Object



62
63
64
# File 'lib/transit/transit_types.rb', line 62

def self.from_base64(data)
  new(Base64.decode64(data))
end

Instance Method Details

#to_base64Object



66
67
68
# File 'lib/transit/transit_types.rb', line 66

def to_base64
  Base64.encode64(@value)
end

#to_sObject

For human-readable display only. Use value() for programmatic consumption of the decoded value.

Forces the platform's default external encoding, which is potentially lossy, but also guarantees that something will be printed instead of raising an error when there is no encoding information provided.



77
78
79
# File 'lib/transit/transit_types.rb', line 77

def to_s
  @value.dup.force_encoding(Encoding.default_external)
end