-
-
Notifications
You must be signed in to change notification settings - Fork 16
拡張のブロック(Music, Pen, Video)をRubyに変換します #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,65 @@ | ||||||
| /** | ||||||
| * Define Ruby code generator for Music Blocks | ||||||
| * @param {RubyGenerator} Generator The RubyGenerator | ||||||
| * @return {RubyGenerator} same as param. | ||||||
| */ | ||||||
| export default function (Generator) { | ||||||
| Generator.music_playDrumForBeats = function (block) { | ||||||
| const drum = Generator.valueToCode(block, 'DRUM', Generator.ORDER_NONE) || null; | ||||||
| const beats = Generator.valueToCode(block, 'BEATS', Generator.ORDER_NONE) || 0; | ||||||
| return `play_drum(drum: ${drum}, beats: ${beats})\n`; | ||||||
| }; | ||||||
|
|
||||||
| Generator.music_menu_DRUM = function (block) { | ||||||
| const drum = Generator.quote_(Generator.getFieldValue(block, 'DRUM') || '1'); | ||||||
| return [drum, Generator.ORDER_ATOMIC]; | ||||||
| }; | ||||||
|
|
||||||
| Generator.music_restForBeats = function (block) { | ||||||
| const beats = Generator.valueToCode(block, 'BEATS', Generator.ORDER_NONE) || 0; | ||||||
| return `rest(${beats})\n`; | ||||||
| }; | ||||||
|
|
||||||
| Generator.music_playNoteForBeats = function (block) { | ||||||
| const note = Generator.valueToCode(block, 'NOTE', Generator.ORDER_NONE) || 0; | ||||||
| const beats = Generator.valueToCode(block, 'BEATS', Generator.ORDER_NONE) || 0; | ||||||
| return `play_note(note: ${note}, beats: ${beats})\n`; | ||||||
| }; | ||||||
|
|
||||||
| Generator.music_playNoteForBeats = function (block) { | ||||||
| const note = Generator.valueToCode(block, 'NOTE', Generator.ORDER_NONE) || 0; | ||||||
| const beats = Generator.valueToCode(block, 'BEATS', Generator.ORDER_NONE) || 0; | ||||||
| return `play_note(note: ${note}, beats: ${beats})\n`; | ||||||
| }; | ||||||
|
|
||||||
| Generator.note = function (block) { | ||||||
| const note = Generator.getFieldValue(block, 'NOTE') || 0; | ||||||
| return [note, Generator.ORDER_ATOMIC]; | ||||||
| }; | ||||||
|
|
||||||
| Generator.music_setInstrument = function (block) { | ||||||
| const instrument = Generator.valueToCode(block, 'INSTRUMENT', Generator.ORDER_NONE) || null; | ||||||
| return `set_instrument(${instrument})\n`; | ||||||
takaokouji marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| }; | ||||||
|
|
||||||
| Generator.music_menu_INSTRUMENT = function (block) { | ||||||
| const instrument = Generator.quote_(Generator.getFieldValue(block, 'INSTRUMENT') || '1'); | ||||||
|
||||||
| const instrument = Generator.quote_(Generator.getFieldValue(block, 'INSTRUMENT') || '1'); | |
| const instrument = Generator.getFieldValue(block, 'INSTRUMENT') || 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
数値でいいです。
Ruby -> Blocksにするときに、数値で決めうちだと楽だからです。ユーザーがタイプするのも数値だと楽だしね。

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここも数値の方がよろしいでしょうか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
はい、数値でお願いします。