55 */
66export default function ( Blockly ) {
77 Blockly . Ruby . control_wait = function ( block ) {
8- const secs = Blockly . Ruby . valueToCode ( block , 'DURATION' , Blockly . Ruby . ORDER_NONE ) || '0' ;
8+ const secs = Blockly . Ruby . valueToCode ( block , 'DURATION' , Blockly . Ruby . ORDER_NONE ) || 0 ;
99 return `sleep(${ secs } )\n` ;
1010 } ;
1111
1212 Blockly . Ruby . control_repeat = function ( block ) {
13- const times = Blockly . Ruby . valueToCode ( block , 'TIMES' , Blockly . Ruby . ORDER_NONE ) || '0' ;
14- const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '\n' ;
15-
13+ const times = Blockly . Ruby . valueToCode ( block , 'TIMES' , Blockly . Ruby . ORDER_NONE ) || 0 ;
14+ const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '' ;
1615 return `repeat(${ times } ) do\n${ branch } end\n` ;
1716 } ;
1817
1918 Blockly . Ruby . control_forever = function ( block ) {
20- const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '\n ' ;
19+ const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '' ;
2120 return `forever do\n${ branch } end\n` ;
2221 } ;
2322
2423 Blockly . Ruby . control_if = function ( block ) {
25- const operator = Blockly . Ruby . valueToCode ( block , 'CONDITION' , Blockly . Ruby . ORDER_NONE ) || ' false' ;
26- const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '\n ' ;
24+ const operator = Blockly . Ruby . valueToCode ( block , 'CONDITION' , Blockly . Ruby . ORDER_NONE ) || false ;
25+ const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '' ;
2726 return `if ${ operator } \n${ branch } end\n` ;
2827 } ;
2928
3029 Blockly . Ruby . control_if_else = function ( block ) {
31- const operator = Blockly . Ruby . valueToCode ( block , 'CONDITION' , Blockly . Ruby . ORDER_NONE ) || ' false' ;
32- const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '\n ' ;
33- const branch2 = Blockly . Ruby . statementToCode ( block , 'SUBSTACK2' ) || '\n ' ;
30+ const operator = Blockly . Ruby . valueToCode ( block , 'CONDITION' , Blockly . Ruby . ORDER_NONE ) || false ;
31+ const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '' ;
32+ const branch2 = Blockly . Ruby . statementToCode ( block , 'SUBSTACK2' ) || '' ;
3433 return `if ${ operator } \n${ branch } else\n${ branch2 } end\n` ;
3534 } ;
3635
3736 Blockly . Ruby . control_wait_until = function ( block ) {
38- const operator = Blockly . Ruby . valueToCode ( block , 'CONDITION' , Blockly . Ruby . ORDER_NONE ) || ' false' ;
37+ const operator = Blockly . Ruby . valueToCode ( block , 'CONDITION' , Blockly . Ruby . ORDER_NONE ) || false ;
3938 return `wait until ${ operator } \n` ;
4039 } ;
4140
4241 Blockly . Ruby . control_repeat_until = function ( block ) {
43- const operator = Blockly . Ruby . valueToCode ( block , 'CONDITION' , Blockly . Ruby . ORDER_NONE ) || ' false' ;
44- const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '\n ' ;
45- return `until ${ operator } \n${ branch } end \n` ;
42+ const operator = Blockly . Ruby . valueToCode ( block , 'CONDITION' , Blockly . Ruby . ORDER_NONE ) || false ;
43+ const branch = Blockly . Ruby . statementToCode ( block , 'SUBSTACK' ) || '' ;
44+ return `until ${ operator } \n${ branch } wait\nend \n` ;
4645 } ;
4746
4847 Blockly . Ruby . control_stop = function ( block ) {
49- const target = Blockly . Ruby . quote_ ( block . getFieldValue ( 'STOP_OPTION' ) || null ) ;
48+ const target = Blockly . Ruby . quote_ ( block . getFieldValue ( 'STOP_OPTION' ) || 'all' ) ;
5049 return `stop(${ target } )\n` ;
5150 } ;
5251
@@ -56,12 +55,12 @@ export default function (Blockly) {
5655 } ;
5756
5857 Blockly . Ruby . control_create_clone_of = function ( block ) {
59- const target = Blockly . Ruby . valueToCode ( block , 'CLONE_OPTION' , Blockly . Ruby . ORDER_NONE ) || null ;
58+ const target = Blockly . Ruby . valueToCode ( block , 'CLONE_OPTION' , Blockly . Ruby . ORDER_NONE ) ;
6059 return `create_clone(${ target } )\n` ;
6160 } ;
6261
6362 Blockly . Ruby . control_create_clone_of_menu = function ( block ) {
64- const target = Blockly . Ruby . quote_ ( block . getFieldValue ( 'CLONE_OPTION' ) || null ) ;
63+ const target = Blockly . Ruby . quote_ ( block . getFieldValue ( 'CLONE_OPTION' ) || '_myself_' ) ;
6564 return [ target , Blockly . Ruby . ORDER_ATOMIC ] ;
6665 } ;
6766
0 commit comments