Class: CLOptionType

Inherits:
CLType show all
Defined in:
lib/types/cl_option_type.rb

Constant Summary

Constants inherited from CLType

CLType::TAGS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CLType

#get_cl_type_tag, #get_link_to, #get_tag_key, #get_tag_value, #get_tags, #tag_value_isvalid

Constructor Details

#initialize(inner = nil) ⇒ CLOptionType

Returns a new instance of CLOptionType.

[View source]

13
14
15
16
17
18
19
# File 'lib/types/cl_option_type.rb', line 13

def initialize(inner = nil)
  @tag = TAGS[:Option]
  @inner = inner
  # p @inner.to_string
  # p @inner.to_json
  # p @inner.get_tag
end

Class Method Details

.to_stringObject

[View source]

45
46
47
# File 'lib/types/cl_option_type.rb', line 45

def self.to_string
  TAGS.key(13).to_s
end

Instance Method Details

#get_inner_typeObject

[View source]

36
37
38
# File 'lib/types/cl_option_type.rb', line 36

def get_inner_type
  @inner
end

#get_typeObject

[View source]

32
33
34
# File 'lib/types/cl_option_type.rb', line 32

def get_type
  TAGS.key(13).to_s
end

#to_bytesObject

[View source]

40
41
42
43
# File 'lib/types/cl_option_type.rb', line 40

def to_bytes
  arr = []
  arr << @tag << @inner.get_tag
end

#to_jsonObject

[View source]

26
27
28
29
30
# File 'lib/types/cl_option_type.rb', line 26

def to_json
  jsoned =  { "#{TAGS.key(13)}": @inner.to_string }.to_json
  # h = JSON.parse(jsoned)
  # h
end

#to_stringString

Returns:

  • (String)
[View source]

22
23
24
# File 'lib/types/cl_option_type.rb', line 22

def to_string
  @inner == nil ? TAGS.key(13).to_s + " (None)" : TAGS.key(13).to_s + " (#{@inner.to_string})"
end