Class: BlocklyInterpreter::DSL::BinaryOperationBlockBuilder
- Inherits:
-
BlockBuilder
- Object
- BlockBuilder
- BlocklyInterpreter::DSL::BinaryOperationBlockBuilder
- Defined in:
- lib/blockly_interpreter/dsl.rb
Direct Known Subclasses
ExtensionBlocks::ListsIncludeOperatorBlock::DSLMethods::ListIncludesBlockBuilder
Instance Attribute Summary
Attributes inherited from BlockBuilder
#block_type, #comment, #comment_pinned, #fields, #is_shadow, #mutation_attrs, #mutation_child_procs, #statements, #values, #x, #y
Instance Method Summary collapse
- #a(static_value = nil, &proc) ⇒ Object
- #b(static_value = nil, &proc) ⇒ Object
- #cast_static_value_proc(static_value) ⇒ Object
-
#initialize(block_type, op, a = nil, b = nil) ⇒ BinaryOperationBlockBuilder
constructor
A new instance of BinaryOperationBlockBuilder.
- #value_with_static_option(name, static_value = nil, &proc) ⇒ Object
Methods inherited from BlockBuilder
#build_subblock, #comment_to_xml, #field, #field_to_xml, #mutation_attr, #mutation_child, #mutations_to_xml, #set_comment, #set_position!, #shadow!, #statement, #subblock_to_xml, #tag_name, #to_xml, #value
Constructor Details
#initialize(block_type, op, a = nil, b = nil) ⇒ BinaryOperationBlockBuilder
Returns a new instance of BinaryOperationBlockBuilder.
188 189 190 191 192 193 194 |
# File 'lib/blockly_interpreter/dsl.rb', line 188 def initialize(block_type, op, a = nil, b = nil) super block_type field :OP, op a(a) unless a.nil? b(b) unless b.nil? end |
Instance Method Details
#a(static_value = nil, &proc) ⇒ Object
209 210 211 |
# File 'lib/blockly_interpreter/dsl.rb', line 209 def a(static_value = nil, &proc) value_with_static_option :A, static_value, &proc end |
#b(static_value = nil, &proc) ⇒ Object
213 214 215 |
# File 'lib/blockly_interpreter/dsl.rb', line 213 def b(static_value = nil, &proc) value_with_static_option :B, static_value, &proc end |
#cast_static_value_proc(static_value) ⇒ Object
196 197 198 199 200 201 202 |
# File 'lib/blockly_interpreter/dsl.rb', line 196 def cast_static_value_proc(static_value) case static_value when Numeric then -> { math_number(static_value) } when String then -> { text(static_value) } when true, false then -> { logic_boolean(static_value) } end end |
#value_with_static_option(name, static_value = nil, &proc) ⇒ Object
204 205 206 207 |
# File 'lib/blockly_interpreter/dsl.rb', line 204 def value_with_static_option(name, static_value = nil, &proc) proc ||= cast_static_value_proc(static_value) value name, &proc end |