Class: Renderer::Component
- Inherits:
-
Object
show all
- Defined in:
- lib/renderer/component.rb,
lib/renderer/component/footer.rb,
lib/renderer/component/symbol.rb,
lib/renderer/component/doc_box.rb,
lib/renderer/component/tab_bar.rb,
lib/renderer/component/typedef.rb,
lib/renderer/component/checkbox.rb,
lib/renderer/component/markdown.rb,
lib/renderer/component/attribute.rb,
lib/renderer/component/reference.rb,
lib/renderer/component/breadcrumb.rb,
lib/renderer/component/text_block.rb,
lib/renderer/component/field_block.rb,
lib/renderer/component/method_list.rb,
lib/renderer/component/class_header.rb,
lib/renderer/component/class_mod_name.rb,
lib/renderer/component/component_list.rb,
lib/renderer/component/method_display.rb,
lib/renderer/component/project_header.rb,
lib/renderer/component/method_argument.rb,
lib/renderer/component/type_definition.rb,
lib/renderer/component/constant_display.rb,
lib/renderer/component/attribute_display.rb,
lib/renderer/component/documentation_block.rb,
lib/renderer/component/class_path_reference.rb,
lib/renderer/component/documentation_comment.rb
Direct Known Subclasses
Attribute, AttributeDisplay, Breadcrumb, Checkbox, ClassHeader, ClassModName, ClassPathReference, ComponentList, ConstantDisplay, DocBox, DocumentationBlock, DocumentationComment, FieldBlock, Footer, Markdown, MethodArgument, MethodDisplay, MethodList, ProjectHeader, Reference, Symbol, TabBar, TextBlock, TypeDefinition, Typedef
Defined Under Namespace
Classes: Attribute, AttributeDisplay, Breadcrumb, Checkbox, ClassHeader, ClassModName, ClassPathReference, ComponentList, ConstantDisplay, DocBox, DocumentationBlock, DocumentationComment, FieldBlock, Footer, Markdown, MethodArgument, MethodDisplay, MethodList, ProjectHeader, Reference, Symbol, TabBar, TextBlock, TypeDefinition, Typedef
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(**kwargs) ⇒ Component
Returns a new instance of Component.
28
29
30
31
32
33
34
35
|
# File 'lib/renderer/component.rb', line 28
def initialize(**kwargs)
@id = kwargs.delete(:id)
kwargs.each do |k, v|
raise ArgumentError, "Unknown property #{k} for #{self.class.name}" unless props.include? k
send("#{k}=", v)
end
end
|
Class Attribute Details
18
19
20
21
22
23
|
# File 'lib/renderer/component.rb', line 18
def self.template
return @template_instance if @template_instance
t_name = @template || name.split("::").last.snakify
@template_instance = Template.new(Renderer::TEMPLATES_PATH.join("#{t_name}.erb"))
end
|
Instance Attribute Details
Returns the value of attribute id.
5
6
7
|
# File 'lib/renderer/component.rb', line 5
def id
@id
end
|
Class Method Details
7
8
9
10
11
12
|
# File 'lib/renderer/component.rb', line 7
def self.prop(*)
attr_accessor(*)
@props ||= []
@props.append(*)
end
|
Instance Method Details
37
|
# File 'lib/renderer/component.rb', line 37
def prepare; end
|
25
|
# File 'lib/renderer/component.rb', line 25
def props = @props ||= self.class.instance_variable_get(:@props) || []
|
39
40
41
42
43
44
|
# File 'lib/renderer/component.rb', line 39
def render(&)
prepare
opts = props.to_h { [_1, send(_1)] }
opts[:id] = @id
template.render(HELPERS, **opts, &)
end
|
26
|
# File 'lib/renderer/component.rb', line 26
def template = self.class.template
|