Class: Vk::Schema::Definition::Constant

Inherits:
Vk::Schema::Definition show all
Defined in:
lib/vk/schema/definition/constant.rb

Direct Known Subclasses

Method, Object, Response, Type

Instance Attribute Summary collapse

Attributes inherited from Vk::Schema::Definition

#definition, #schema

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Vk::Schema::Definition

#description, #to_s

Constructor Details

#initialize(name, definition, schema) ⇒ Constant

Returns a new instance of Constant.

Parameters:

  • name (String)
  • definition (Hash{String => String, Hash})
  • schema (Vk::Schema)

15
16
17
18
# File 'lib/vk/schema/definition/constant.rb', line 15

def initialize(name, definition, schema)
  super
  @namespace, @name = name.split(self.class.namespace_splitter, 2)
end

Instance Attribute Details

#nameString (readonly)

Returns:

  • (String)

21
22
23
# File 'lib/vk/schema/definition/constant.rb', line 21

def name
  @name
end

Class Method Details

.namespace_splitterObject


8
9
10
# File 'lib/vk/schema/definition/constant.rb', line 8

def self.namespace_splitter
  @namespace_splitter ||= /_/
end

Instance Method Details

#definition_fileString

Returns:

  • (String)

44
45
46
# File 'lib/vk/schema/definition/constant.rb', line 44

def definition_file
  "lib/#{require}.rb"
end

#namespaceString

Returns:

  • (String)

24
25
26
# File 'lib/vk/schema/definition/constant.rb', line 24

def namespace
  @namespace.camelize
end

#referenced_type_nameString

Returns:

  • (String)

34
35
36
# File 'lib/vk/schema/definition/constant.rb', line 34

def referenced_type_name
  "API::#{namespace}::#{type_name}"
end

#requireString

Returns:

  • (String)

39
40
41
# File 'lib/vk/schema/definition/constant.rb', line 39

def require
  "vk/api/#{@namespace}/#{@name}"
end

#spec_fileString

Returns:

  • (String)

49
50
51
# File 'lib/vk/schema/definition/constant.rb', line 49

def spec_file
  "spec/#{require}_spec.rb"
end

#type_nameString

Returns:

  • (String)

29
30
31
# File 'lib/vk/schema/definition/constant.rb', line 29

def type_name
  @type_name ||= name.camelize
end