Skip to content

Commit 6091891

Browse files
committed
ruby-to-blocks-converterにwedo2を追加
1 parent e92732f commit 6091891

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/lib/ruby-to-blocks-converter/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import VariablesConverter from './variables';
1919
import MyBlocksConverter from './my-blocks';
2020
import MusicConverter from './music';
2121
import EV3Converter from './ev3';
22+
import Wedo2Converter from './wedo2';
2223

2324
/**
2425
* Class for a block converter that translates ruby code into the blocks.
@@ -37,7 +38,8 @@ class RubyToBlocksConverter {
3738
VariablesConverter,
3839
MyBlocksConverter,
3940
MusicConverter,
40-
EV3Converter
41+
EV3Converter,
42+
Wedo2Converter
4143
];
4244
this.reset();
4345
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* global Opal */
2+
import _ from 'lodash';
3+
4+
const RotationStyle = [
5+
'left-right',
6+
'don\'t rotate',
7+
'all around'
8+
];
9+
10+
/**
11+
* Wedo2 converter
12+
*/
13+
const Wedo2Converter = {
14+
// eslint-disable-next-line no-unused-vars
15+
onSend: function (receiver, name, args, rubyBlockArgs, rubyBlock) {
16+
let block;
17+
if ((this._isSelf(receiver) || receiver === Opal.nil) && !rubyBlock) {
18+
switch (name) {
19+
case 'wedo2_set_light_color':
20+
if (args.length === 1 && this._isNumberOrBlock(args[0])) {
21+
block = this._createBlock('wedo2_setLightHue', 'statement');
22+
this._addNumberInput(block, 'HUE', 'math_number', args[0], 50);
23+
}
24+
break;
25+
}
26+
}
27+
return block;
28+
}
29+
};
30+
31+
export default Wedo2Converter;

0 commit comments

Comments
 (0)