Class: RgGen::Core::OutputBase::Component

Inherits:
Base::Component show all
Includes:
Base::ComponentLayerExtension
Defined in:
lib/rggen/core/output_base/component.rb

Defined Under Namespace

Classes: CodeGeneratorContext

Instance Attribute Summary collapse

Attributes inherited from Base::Component

#children, #component_index, #depth, #layer, #parent

Instance Method Summary collapse

Methods inherited from Base::Component

#add_child, #ancestors, #component_name, #feature, #features, #initialize, #need_children?, #need_no_children

Constructor Details

This class inherits a constructor from RgGen::Core::Base::Component

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



9
10
11
# File 'lib/rggen/core/output_base/component.rb', line 9

def configuration
  @configuration
end

#register_mapObject (readonly)

Returns the value of attribute register_map.



10
11
12
# File 'lib/rggen/core/output_base/component.rb', line 10

def register_map
  @register_map
end

Instance Method Details

#add_feature(feature) ⇒ Object



24
25
26
27
# File 'lib/rggen/core/output_base/component.rb', line 24

def add_feature(feature)
  super
  import_feature_methods(feature, :class)
end

#buildObject



37
38
39
40
# File 'lib/rggen/core/output_base/component.rb', line 37

def build
  @features.each_value(&method(:build_feature))
  @children.each(&:build)
end

#children?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rggen/core/output_base/component.rb', line 20

def children?
  !register_map.children.empty?
end

#generate_code(code, kind, mode, target_or_range = nil, depth = 0) ⇒ Object



42
43
44
45
# File 'lib/rggen/core/output_base/component.rb', line 42

def generate_code(code, kind, mode, target_or_range = nil, depth = 0)
  code_generator_contexts(kind, mode, target_or_range, depth)
    .each { |context| context.generate(code) }
end

#post_initialize(configuration, register_map) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/rggen/core/output_base/component.rb', line 12

def post_initialize(configuration, register_map)
  @configuration = configuration
  @register_map = register_map
  @need_children = register_map.need_children?
  define_layer_methods
  define_proxy_calls(@register_map, @register_map.properties)
end

#pre_buildObject



33
34
35
# File 'lib/rggen/core/output_base/component.rb', line 33

def pre_build
  @features.each_value(&:pre_build)
end

#printablesObject



29
30
31
# File 'lib/rggen/core/output_base/component.rb', line 29

def printables
  register_map.printables
end

#write_file(directory = nil) ⇒ Object



47
48
49
50
# File 'lib/rggen/core/output_base/component.rb', line 47

def write_file(directory = nil)
  @features.each_value { |feature| feature.write_file(directory) }
  @children.each { |component| component.write_file(directory) }
end