Class: KRPC::Types::DictionaryType

Inherits:
TypeBase
  • Object
show all
Defined in:
lib/krpc/types.rb

Instance Attribute Summary collapse

Attributes inherited from TypeBase

#protobuf_type, #ruby_type

Instance Method Summary collapse

Constructor Details

#initialize(type_string) ⇒ DictionaryType

Returns a new instance of DictionaryType.

Raises:



196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/krpc/types.rb', line 196

def initialize(type_string)
  m = /^Dictionary\((.+)\)$/.match type_string
  raise(ValueError, "\"#{type_string}\" is not a valid type string for a dictionary type") unless m

  key_string, type   = parse_type_string(m[1])
  value_string, type = parse_type_string(type)
  raise(ValueError, "\"#{type_string}\" is not a valid type string for a dictionary type") unless type.nil?
  @key_type   = TypeStore[key_string]
  @value_type = TypeStore[value_string]

  super(type_string, Hash)
end

Instance Attribute Details

#key_typeObject (readonly)

Returns the value of attribute key_type.



195
196
197
# File 'lib/krpc/types.rb', line 195

def key_type
  @key_type
end

#value_typeObject (readonly)

Returns the value of attribute value_type.



195
196
197
# File 'lib/krpc/types.rb', line 195

def value_type
  @value_type
end