Class: Languages::ClassData

Inherits:
BasicData show all
Defined in:
lib/kuniri/language/container_data/structured_and_oo/class_data.rb

Overview

Handling class information

Instance Attribute Summary collapse

Attributes inherited from BasicData

#comments, #name, #visibility

Instance Method Summary collapse

Constructor Details

#initializeClassData

Returns a new instance of ClassData.



20
21
22
23
24
25
26
27
28
# File 'lib/kuniri/language/container_data/structured_and_oo/class_data.rb', line 20

def initialize
  @inheritances = []
  @attributes = []
  @methods = []
  @constructors = []
  @aggregations = []
  @visibility = "public"
  @comments = ""
end

Instance Attribute Details

#aggregationsObject

Returns the value of attribute aggregations.



15
16
17
# File 'lib/kuniri/language/container_data/structured_and_oo/class_data.rb', line 15

def aggregations
  @aggregations
end

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#constructorsObject (readonly)

Returns the value of attribute constructors.



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

def constructors
  @constructors
end

#inheritancesObject

Returns the value of attribute inheritances.



14
15
16
# File 'lib/kuniri/language/container_data/structured_and_oo/class_data.rb', line 14

def inheritances
  @inheritances
end

#methodsObject (readonly)

Returns the value of attribute methods.



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

def methods
  @methods
end

Instance Method Details

#add_aggregation(pAggregation) ⇒ Object

Add aggregation inside class.

Parameters:

  • pAggregation

    Object of AggregationData to be added at class.



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

def add_aggregation(pAggregation)
  return nil unless pAggregation.is_a?(Languages::AggregationData)

  @aggregations.push(pAggregation)
end

#add_attribute(pAttribute) ⇒ Object

Add attribute to class data, notice the possibility of call this method more than one time.

Parameters:

  • pAttribute

    Attribute to be added inside class. This attribute is a list of AttributeData.



34
35
36
37
38
39
# File 'lib/kuniri/language/container_data/structured_and_oo/class_data.rb', line 34

def add_attribute(pAttribute)
  pAttribute.each do |attributeElement|
    next unless attributeElement.is_a?(Languages::AttributeData)
    @attributes.push(attributeElement)
  end
end

#add_constructor(pConstructor) ⇒ Object

Add constructor inside class.

Parameters:

  • pConstructor

    Object of FunctionData to be added at class.



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

def add_constructor(pConstructor)
  return nil unless pConstructor.is_a?(Languages::ConstructorData)

  @constructors.push(pConstructor)
end

#add_method(pMethod) ⇒ Object

Add method inside ClassData. Remember the possibility of have zero or any method inside a class.

Parameters:

  • pMethod

    It is an object of FunctionData with the method informations.



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

def add_method(pMethod)
  return nil unless pMethod.is_a?(Languages::MethodData)

  @methods.push(pMethod)
end