Class: KRPC::Types::EnumType

Inherits:
TypeBase 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) ⇒ EnumType

Returns a new instance of EnumType.

Raises:



171
172
173
174
175
176
177
# File 'lib/krpc/types.rb', line 171

def initialize(type_string)
  m = /Enum\(([^\.]+)\.([^\.]+)\)/.match type_string
  raise(ValueError, "\"#{type_string}\" is not a valid type string for a enumeration type") unless m
  @service_name, @enum_name = m[1..2]
  # Sets ruby_type to nil, set_values must be called to set the ruby_type
  super(type_string, nil)
end

Instance Attribute Details

#enum_nameObject (readonly)

Returns the value of attribute enum_name.



170
171
172
# File 'lib/krpc/types.rb', line 170

def enum_name
  @enum_name
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



170
171
172
# File 'lib/krpc/types.rb', line 170

def service_name
  @service_name
end

Instance Method Details

#set_values(values) ⇒ Object



179
180
181
# File 'lib/krpc/types.rb', line 179

def set_values(values)
  @ruby_type = Gen.generate_enum(service_name, enum_name, values)
end