Class: ElementClassVars

Inherits:
Object
  • Object
show all
Defined in:
lib/tdl/exlib/element_class_vars.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name) ⇒ ElementClassVars

Returns a new instance of ElementClassVars.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tdl/exlib/element_class_vars.rb', line 9

def initialize(class_name)
    @name = class_name.to_s
    @class_name = class_name
    @id = 1
    @pre_inst = []
    @pre_inst_stack = []
    @inst_stack = []
    @draw_stack = []
    @draw_nc = []
    @ports = []
    @nc = nil
    @nc_id = 0

    @expression = []
    @expression_def = []
    @expression_record = []
    @condition_expression = []

    @expression_record.define_singleton_method("[]") do |key|
        if @expression_record.include? key
            @expression_record << key
            true
        else
            false
        end
    end
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



4
5
6
# File 'lib/tdl/exlib/element_class_vars.rb', line 4

def class_name
  @class_name
end

#condition_expressionObject

Returns the value of attribute condition_expression.



7
8
9
# File 'lib/tdl/exlib/element_class_vars.rb', line 7

def condition_expression
  @condition_expression
end

#draw_ncObject

Returns the value of attribute draw_nc.



5
6
7
# File 'lib/tdl/exlib/element_class_vars.rb', line 5

def draw_nc
  @draw_nc
end

#draw_stackObject

Returns the value of attribute draw_stack.



5
6
7
# File 'lib/tdl/exlib/element_class_vars.rb', line 5

def draw_stack
  @draw_stack
end

#expressionObject

Returns the value of attribute expression.



7
8
9
# File 'lib/tdl/exlib/element_class_vars.rb', line 7

def expression
  @expression
end

#expression_defObject

Returns the value of attribute expression_def.



7
8
9
# File 'lib/tdl/exlib/element_class_vars.rb', line 7

def expression_def
  @expression_def
end

#expression_recordObject

Returns the value of attribute expression_record.



7
8
9
# File 'lib/tdl/exlib/element_class_vars.rb', line 7

def expression_record
  @expression_record
end

#inst_stackObject

Returns the value of attribute inst_stack.



5
6
7
# File 'lib/tdl/exlib/element_class_vars.rb', line 5

def inst_stack
  @inst_stack
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/tdl/exlib/element_class_vars.rb', line 4

def name
  @name
end

#portsObject

Returns the value of attribute ports.



5
6
7
# File 'lib/tdl/exlib/element_class_vars.rb', line 5

def ports
  @ports
end

#pre_instObject

Returns the value of attribute pre_inst.



5
6
7
# File 'lib/tdl/exlib/element_class_vars.rb', line 5

def pre_inst
  @pre_inst
end

#pre_inst_stackObject

Returns the value of attribute pre_inst_stack.



5
6
7
# File 'lib/tdl/exlib/element_class_vars.rb', line 5

def pre_inst_stack
  @pre_inst_stack
end

Instance Method Details

#idObject



71
72
73
74
75
# File 'lib/tdl/exlib/element_class_vars.rb', line 71

def id
    tmp = @id
    @id = @id + 1
    tmp
end

#ncObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/tdl/exlib/element_class_vars.rb', line 38

def nc
    unless @nc
        @nc = @class_name.nc_create

        # @nc.define_singleton_method(:signal) do
        #     nid = @nc_id
        #     @nc_id += 1
        #     nid
        # end
        @nc.instance_variable_set("@_id",0)

        class << @nc

            def signal
                @_id ||= 0
                nid = @_id
                @_id += 1
                nid.to_s
            end

            def peak_signal
                @_id ||= 0
                nid = @_id
                nid.to_s
            end

        end
        @nc
    else
        @nc
    end
end