Skip to content

Commit 92e56ab

Browse files
committed
EV3のbeepを追加
1 parent aa508be commit 92e56ab

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* global Opal */
2+
import _ from 'lodash';
3+
4+
const RotationStyle = [
5+
'left-right',
6+
'don\'t rotate',
7+
'all around'
8+
];
9+
10+
const Ev3MotorMenu = ['A', 'B', 'C', 'D'];
11+
12+
/**
13+
* EV3 converter
14+
*/
15+
const EV3Converter = {
16+
// eslint-disable-next-line no-unused-vars
17+
onSend: function (receiver, name, args, rubyBlockArgs, rubyBlock) {
18+
let block;
19+
if ((this._isSelf(receiver) || receiver === Opal.nil) && !rubyBlock) {
20+
switch (name) {
21+
case 'ev3_beep_note':
22+
if (args.length === 2 && this._isNumberOrBlock(args[0]) && this._isNumberOrBlock(args[1])) {
23+
block = this._createBlock('ev3_beep', 'statement');
24+
this._addNumberInput(block, 'NOTE', 'math_number', args[0], 60);
25+
this._addNumberInput(block, 'TIME', 'math_number', args[1], 0.5);
26+
}
27+
break;
28+
}
29+
}
30+
return block;
31+
},
32+
};
33+
34+
export default EV3Converter;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import OperatorsConverter from './operators';
1818
import VariablesConverter from './variables';
1919
import MyBlocksConverter from './my-blocks';
2020
import MusicConverter from './music';
21+
import EV3Converter from './ev3';
2122

2223
/**
2324
* Class for a block converter that translates ruby code into the blocks.
@@ -35,7 +36,8 @@ class RubyToBlocksConverter {
3536
OperatorsConverter,
3637
VariablesConverter,
3738
MyBlocksConverter,
38-
MusicConverter
39+
MusicConverter,
40+
EV3Converter
3941
];
4042
this.reset();
4143
}

0 commit comments

Comments
 (0)