Class: Borsh::String
- Inherits:
-
Object
- Object
- Borsh::String
- Defined in:
- lib/borsh/string.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ String
constructor
A new instance of String.
- #to_borsh ⇒ Object
Constructor Details
#initialize(value) ⇒ String
Returns a new instance of String.
2 3 4 |
# File 'lib/borsh/string.rb', line 2 def initialize(value) @value = value end |
Instance Method Details
#to_borsh ⇒ Object
6 7 8 9 10 11 |
# File 'lib/borsh/string.rb', line 6 def to_borsh length = [value.length].pack('V') raise Borsh::ArgumentError, 'string too long' if length.unpack('V') != [value.length] length + value end |