Class: RgGen::Builder::Builder
- Inherits:
-
Object
- Object
- RgGen::Builder::Builder
- Defined in:
- lib/rggen/builder/builder.rb
Constant Summary collapse
- INITIAL_CATEGORIES =
[ :global, :register_block, :register, :bit_field ].freeze
Instance Attribute Summary collapse
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
Instance Method Summary collapse
- #build_factory(component_name) ⇒ Object
- #define_list_item(category_name, list_name, item_name = nil, &body) ⇒ Object
- #define_loader(component_name, type_or_types, &body) ⇒ Object
- #define_simple_item(category_name, item_name, &body) ⇒ Object
- #enable(category_name, *args) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #input_component_store(component_name, &body) ⇒ Object
- #output_component_store(component_name, &body) ⇒ Object
- #stored_output_components ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rggen/builder/builder.rb', line 11 def initialize @stores = Hash.new do |_, component_name| fail RgGen::BuilderError, "unknown component: #{component_name}" end @categories = Hash.new do |_, category_name| fail RgGen::BuilderError, "unknown category: #{category_name}" end INITIAL_CATEGORIES.each do |category_name| @categories[category_name] = Category.new end end |
Instance Attribute Details
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
23 24 25 |
# File 'lib/rggen/builder/builder.rb', line 23 def categories @categories end |
Instance Method Details
#build_factory(component_name) ⇒ Object
43 44 45 |
# File 'lib/rggen/builder/builder.rb', line 43 def build_factory(component_name) @stores[component_name].build_factory end |
#define_list_item(category_name, list_name, item_name = nil, &body) ⇒ Object
51 52 53 |
# File 'lib/rggen/builder/builder.rb', line 51 def define_list_item(category_name, list_name, item_name = nil, &body) @categories[category_name].define_list_item(list_name, item_name, &body) end |
#define_loader(component_name, type_or_types, &body) ⇒ Object
39 40 41 |
# File 'lib/rggen/builder/builder.rb', line 39 def define_loader(component_name, type_or_types, &body) @stores[component_name].define_loader(type_or_types, &body) end |
#define_simple_item(category_name, item_name, &body) ⇒ Object
47 48 49 |
# File 'lib/rggen/builder/builder.rb', line 47 def define_simple_item(category_name, item_name, &body) @categories[category_name].define_simple_item(item_name, &body) end |
#enable(category_name, *args) ⇒ Object
55 56 57 |
# File 'lib/rggen/builder/builder.rb', line 55 def enable(category_name, *args) @categories[category_name].enable(*args) end |
#input_component_store(component_name, &body) ⇒ Object
25 26 27 |
# File 'lib/rggen/builder/builder.rb', line 25 def input_component_store(component_name, &body) component_store(InputComponentStore, component_name, body) end |
#output_component_store(component_name, &body) ⇒ Object
29 30 31 |
# File 'lib/rggen/builder/builder.rb', line 29 def output_component_store(component_name, &body) component_store(OutputComponentStore, component_name, body) end |
#stored_output_components ⇒ Object
33 34 35 36 37 |
# File 'lib/rggen/builder/builder.rb', line 33 def stored_output_components @stores.keys.select do |component_name| @stores[component_name].is_a?(OutputComponentStore) end end |