Class: Languages::FileElementData

Inherits:
BasicData
  • Object
show all
Defined in:
lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb

Overview

FileElementData is the upper element related with container data, this class refers to file.

Instance Attribute Summary collapse

Attributes inherited from BasicData

#comments, #name, #visibility

Instance Method Summary collapse

Constructor Details

#initialize(pName) ⇒ FileElementData

Returns a new instance of FileElementData.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 22

def initialize(pName)
  return nil if pName.nil? or !pName.is_a? String

  @global_functions = []
  @global_variables = []
  @extern_requirements = []
  @classes = []
  @modules = []
  @name = pName
  @comments = ""
end

Instance Attribute Details

#classesObject (readonly)

Returns the value of attribute classes.



19
20
21
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 19

def classes
  @classes
end

#extern_requirementsObject (readonly)

Returns the value of attribute extern_requirements.



18
19
20
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 18

def extern_requirements
  @extern_requirements
end

#global_functionsObject (readonly)

Returns the value of attribute global_functions.



16
17
18
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 16

def global_functions
  @global_functions
end

#global_variablesObject (readonly)

Returns the value of attribute global_variables.



17
18
19
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 17

def global_variables
  @global_variables
end

#modulesObject (readonly)

Returns the value of attribute modules.



20
21
22
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 20

def modules
  @modules
end

Instance Method Details

#add_class(pClass) ⇒ Object

Add a class inside file.

Parameters:

  • pClass

    Add an object of ClassData.



61
62
63
64
65
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 61

def add_class(pClass)
  return nil unless pClass.is_a?(Languages::ClassData)

  @classes.push(pClass)
end

#add_extern_requirement(pOutside) ⇒ Object

Add extern requirement inside file.

Parameters:

  • pOutside

    Add an object of ExternRequirementData.



53
54
55
56
57
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 53

def add_extern_requirement(pOutside)
  return nil unless pOutside.is_a?(Languages::ExternRequirementData)

  @extern_requirements.push(pOutside)
end

#add_global_function(pFunction) ⇒ Object

Add global function to the file.

Parameters:

  • pFunction

    An object of FunctionData to be added at the file.



36
37
38
39
40
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 36

def add_global_function(pFunction)
  return nil unless pFunction.is_a?(Languages::FunctionData)

  @global_functions.push(pFunction)
end

#add_global_variable(*pVariable) ⇒ Object

Add global variable inside file.

Parameters:

  • pVariable

    A single VariableGlobalData object or list to be added.



44
45
46
47
48
49
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 44

def add_global_variable(*pVariable)
  pVariable.flatten.each do |element|
    next unless element.is_a?(Languages::VariableGlobalData)
    @global_variables.push(element)
  end
end

#add_modules(pModule) ⇒ Object

Add a module inside file.

Parameters:

  • pModule

    Add an object of ModuleNamespaceData



69
70
71
72
73
# File 'lib/kuniri/language/container_data/structured_and_oo/file_element_data.rb', line 69

def add_modules(pModule)
  return nil unless pModule.is_a?(Languages::ModuleNamespaceData)

  @modules.push(pModule)
end