Class: CLString

Inherits:
CLValue show all
Includes:
CLValueBytesParsers::CLStringBytesParser
Defined in:
lib/types/cl_string.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CLValueBytesParsers::CLStringBytesParser

#from_bytes, #from_json, #to_bytes, #to_json

Methods inherited from CLValue

#to_hash

Constructor Details

#initialize(value) ⇒ CLString

Returns a new instance of CLString.



11
12
13
14
15
16
# File 'lib/types/cl_string.rb', line 11

def initialize(value)
  super()
  # raise "error" unless value.is_a?(String)
  raise "error" unless value.instance_of? String
  @value =  value
end

Instance Attribute Details

#cl_valueObject Also known as: clvalue?

Returns the value of attribute cl_value.



7
8
9
# File 'lib/types/cl_string.rb', line 7

def cl_value
  @cl_value
end

Class Method Details

.to_bytes(clvalue) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/types/cl_string.rb', line 31

def self.to_bytes(clvalue)
value = clvalue.get_value
len = value.length
hex1 = len.to_s(16).rjust(8, '0').scan(/../).reverse.join('')
hex2 = value.unpack("H*").first
hex1 + hex2
end

Instance Method Details

#get_cl_typeObject



18
19
20
21
# File 'lib/types/cl_string.rb', line 18

def get_cl_type
  @cl_string_type = CLStringType.new
  @cl_string_type.to_string
end

#get_sizeObject



27
28
29
# File 'lib/types/cl_string.rb', line 27

def get_size
  @value.length
end

#get_valueObject



23
24
25
# File 'lib/types/cl_string.rb', line 23

def get_value
  @value  
end