Class: RLSL::CodeGenerator::TemplateContext
- Inherits:
-
Object
- Object
- RLSL::CodeGenerator::TemplateContext
- Defined in:
- lib/rlsl/code_generator/template_context.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #fragment_code ⇒ Object
- #helpers_code ⇒ Object
-
#initialize(name:, uniforms:, helpers_block:, fragment_block:) ⇒ TemplateContext
constructor
A new instance of TemplateContext.
- #render_arity ⇒ Object
- #uniform_argument_list ⇒ Object
- #uniform_entries ⇒ Object
Constructor Details
#initialize(name:, uniforms:, helpers_block:, fragment_block:) ⇒ TemplateContext
Returns a new instance of TemplateContext.
8 9 10 11 12 13 |
# File 'lib/rlsl/code_generator/template_context.rb', line 8 def initialize(name:, uniforms:, helpers_block:, fragment_block:) @name = name @uniforms = uniforms @helpers_block = helpers_block @fragment_block = fragment_block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rlsl/code_generator/template_context.rb', line 6 def name @name end |
Instance Method Details
#fragment_code ⇒ Object
25 26 27 |
# File 'lib/rlsl/code_generator/template_context.rb', line 25 def fragment_code @fragment_block.call end |
#helpers_code ⇒ Object
19 20 21 22 23 |
# File 'lib/rlsl/code_generator/template_context.rb', line 19 def helpers_code return "" unless @helpers_block @helpers_block.call end |
#render_arity ⇒ Object
15 16 17 |
# File 'lib/rlsl/code_generator/template_context.rb', line 15 def render_arity 3 + @uniforms.size end |
#uniform_argument_list ⇒ Object
35 36 37 38 |
# File 'lib/rlsl/code_generator/template_context.rb', line 35 def uniform_argument_list arguments = @uniforms.map { |uniform_name, _| "VALUE rb_#{uniform_name}" } arguments.empty? ? "" : ", #{arguments.join(', ')}" end |
#uniform_entries ⇒ Object
29 30 31 32 33 |
# File 'lib/rlsl/code_generator/template_context.rb', line 29 def uniform_entries @uniform_entries ||= @uniforms.map do |uniform_name, type| [uniform_name, UniformTypes.compiled_spec(type)] end end |