Class: Vk::Schema::Definition::Type

Inherits:
Constant show all
Defined in:
lib/vk/schema/definition/type.rb

Constant Summary collapse

PRIMITIVES =
Hash.new do |hash, key|
  hash[key] = key.to_s.camelize
end

Instance Attribute Summary

Attributes inherited from Constant

#name

Attributes inherited from Vk::Schema::Definition

#definition, #name, #schema

Instance Method Summary collapse

Methods inherited from Constant

#definition_file, #initialize, #namespace, namespace_splitter, #referenced_type_name, #require, #spec_file, #type_name

Methods inherited from Vk::Schema::Definition

#description, #initialize, #to_s

Constructor Details

This class inherits a constructor from Vk::Schema::Definition::Constant

Instance Method Details

#primitiveObject



25
26
27
# File 'lib/vk/schema/definition/type.rb', line 25

def primitive
  PRIMITIVES[definition['type']]
end

#type_definitionObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/vk/schema/definition/type.rb', line 14

def type_definition
  result = Attribute.type_for(definition['type']).gsub(/^Types::/, '')
  if definition['enum']
    values = definition['enum'].map do |value|
      value.is_a?(String) ? "'#{value}'" : value
    end
    result += ".enum(#{values.join(', ')})"
  end
  result
end