Class: ClassHDL::StructMeta

Inherits:
Object
  • Object
show all
Defined in:
lib/tdl/class_hdl/hdl_struct.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, sdlm, all_var_collect) ⇒ StructMeta

Returns a new instance of StructMeta.



100
101
102
103
104
105
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 100

def initialize(name,sdlm,all_var_collect)
    @name = name
    @sdlm = sdlm 
    @struct_slots = all_var_collect
    @tmp_dimension = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



123
124
125
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 123

def method_missing(method,*args,&block) 
    self - method
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



98
99
100
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 98

def name
  @name
end

#sdlmObject

Returns the value of attribute sdlm.



99
100
101
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 99

def sdlm
  @sdlm
end

#struct_slotsObject (readonly)

Returns the value of attribute struct_slots.



98
99
100
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 98

def struct_slots
  @struct_slots
end

Instance Method Details

#-(varname) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 107

def -(varname)
    rel = StructVar.new(varname,self)
    rel.belong_to_module = @sdlm
    rel.dimension = @tmp_dimension
    @sdlm.Logic_collect << rel
    # rel.belong_to_module = @sdlm

    ## 给 sdlmodule 定义 方法

    @sdlm.define_singleton_method(varname) do
        rel 
    end
    @tmp_dimension = []
    return rel 
end

#[](*args) ⇒ Object



127
128
129
130
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 127

def [](*args)
    @tmp_dimension += args
    return self
end