smalruby-editor 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/demos/default.xml +1 -1
- data/app/assets/javascripts/application.js +1 -0
- data/app/assets/javascripts/blocks/blockly.js.coffee.erb +1 -1
- data/app/assets/javascripts/blocks/events.js.coffee.erb +2 -3
- data/app/assets/javascripts/blocks/field_character.js.coffee.erb +108 -0
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +35 -2
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +4 -4
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +27 -29
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +4 -6
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +21 -19
- data/app/assets/javascripts/models/character.js.coffee +21 -0
- data/app/assets/javascripts/views/character_modal_view.js.coffee +24 -3
- data/app/views/editor/_character_modal.html.haml +1 -1
- data/app/views/editor/_toolbox.html.haml +7 -3
- data/lib/smalruby_editor/version.rb +1 -1
- data/public/assets/{application-0c2ae32cd8822cec7ba6e445e2501010.js → application-735e172a0df828da16d22f5d3c26671f.js} +294 -59
- data/public/assets/{application-0c2ae32cd8822cec7ba6e445e2501010.js.gz → application-735e172a0df828da16d22f5d3c26671f.js.gz} +0 -0
- data/public/assets/{default-7f438ebd7f8ab6ef65c5b9744786e57f.xml → default-5d1886100d7c8961e9962bbc4bb0c714.xml} +1 -1
- data/public/assets/manifest-1f254fa92a71ba4faad0f99136daeed8.json +1 -1
- data/spec/acceptance/block_mode/blocks/hardware/servo_set_position.feature +104 -0
- data/spec/acceptance/block_mode/blocks/operators/and_or.feature +61 -0
- data/spec/acceptance/block_mode/blocks/operators/four_arithmetic_and_compares.feature +85 -0
- data/spec/acceptance/block_mode/blocks/operators/index_of.feature +60 -0
- data/spec/acceptance/block_mode/blocks/operators/length.feature +52 -0
- data/spec/acceptance/block_mode/blocks/operators/math_method.feature +109 -0
- data/spec/acceptance/block_mode/blocks/operators/negate.feature +47 -0
- data/spec/acceptance/block_mode/blocks/operators/rand.feature +60 -0
- data/spec/acceptance/block_mode/blocks/operators/round.feature +52 -0
- data/spec/acceptance/block_mode/blocks/operators/true_false.feature +36 -0
- data/spec/acceptance/block_mode/blocks/ruby/expression.feature +36 -0
- data/spec/acceptance/block_mode/blocks/ruby/p.feature +34 -0
- data/spec/acceptance/block_mode/blocks/ruby/statement_comment.feature +25 -0
- data/spec/javascripts/models/character_spec.coffee +44 -5
- data/spec/steps/ace_steps.rb +9 -0
- data/spec/steps/block_mode_steps.rb +14 -0
- data/spec/steps/fix_turnip.rb +35 -0
- data/spec/steps/text_editor_steps.rb +1 -0
- data/spec/teaspoon_env.rb +1 -1
- data/spec/turnip_helper.rb +1 -0
- metadata +34 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20db57ce467ebe6941df084c8dcb09680189e490
|
4
|
+
data.tar.gz: 4f1bbcc5b25609c155b2838344ee79e5afc3f08c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 274bdb33cf8848860654c4989af58f96b0903b10e12fd9087d6ef77f1915d9f96e0a40173e638f6418047650f88f2e47fe79cbd1a6efdf33567fe4a99c4561b7
|
7
|
+
data.tar.gz: 59966ae04b1324d73a6795e45a878b1ae55c50a3789e64542ade4b62fa0a5b23d04c67fb91c1b73ef27b29cb81d441c5c54f3158142d6056775b5b5afb1da1a7
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<% n = "#{category}_number" %>
|
6
6
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
7
7
|
code = parseFloat(@getFieldValue('NUM'))
|
8
|
-
order = if code < 0 then Blockly.Ruby.
|
8
|
+
order = if code < 0 then Blockly.Ruby.ORDER_UNARY_MINUS_SIGN else Blockly.Ruby.ORDER_ATOMIC
|
9
9
|
[code, order]
|
10
10
|
|
11
11
|
|
@@ -69,7 +69,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
69
69
|
@setHelpUrl('')
|
70
70
|
@setColour(<%= color %>)
|
71
71
|
@appendDummyInput()
|
72
|
-
.appendField(new
|
72
|
+
.appendField(new Smalruby.FieldCharacter(), 'CHAR') # TODO
|
73
73
|
.appendField('にぶつかったとき')
|
74
74
|
@appendStatementInput('DO')
|
75
75
|
@setPreviousStatement(true)
|
@@ -77,6 +77,5 @@ Blockly.Blocks['<%= n %>'] =
|
|
77
77
|
@setTooltip('')
|
78
78
|
|
79
79
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
80
|
-
char =
|
81
|
-
.getName(block.getFieldValue('CHAR'), Blockly.Variables.NAME_TYPE)
|
80
|
+
char = @getFieldValue('CHAR')
|
82
81
|
Blockly.Ruby.characterEvent_(block, 'DO', 'hit', char)
|
@@ -0,0 +1,108 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
goog.provide('Smalruby.FieldCharacter')
|
4
|
+
|
5
|
+
goog.require('Blockly.FieldDropdown')
|
6
|
+
|
7
|
+
|
8
|
+
Smalruby.FieldCharacter = (character, opt_changeHandler) ->
|
9
|
+
if opt_changeHandler
|
10
|
+
changeHandler = (value) =>
|
11
|
+
retVal = Smalruby.FieldCharacter.dropdownChange.call(@, value)
|
12
|
+
if retVal
|
13
|
+
newVal = retVal
|
14
|
+
else
|
15
|
+
retVal = @getValue()
|
16
|
+
opt_changeHandler.call(@, newVal)
|
17
|
+
retVal
|
18
|
+
else
|
19
|
+
changeHandler = Smalruby.FieldCharacter.dropdownChange
|
20
|
+
|
21
|
+
Smalruby.FieldCharacter.superClass_.constructor
|
22
|
+
.call(@, Smalruby.FieldCharacter.dropdownCreate, changeHandler)
|
23
|
+
|
24
|
+
charSet = Smalruby.Collections.CharacterSet
|
25
|
+
charSet.on('add', @onCharacterSetAdd_, @)
|
26
|
+
charSet.on('remove', @onCharacterSetRemove_, @)
|
27
|
+
charSet.on('reset', @onCharacterSetReset_, @)
|
28
|
+
|
29
|
+
@character = Smalruby.FieldCharacter.NullCharacter
|
30
|
+
|
31
|
+
unless character
|
32
|
+
character = Smalruby.Collections.CharacterSet.first()
|
33
|
+
@setCharacter(character)
|
34
|
+
|
35
|
+
goog.inherits(Smalruby.FieldCharacter, Blockly.FieldDropdown)
|
36
|
+
|
37
|
+
Smalruby.FieldCharacter.prototype.setCharacter = (character) ->
|
38
|
+
return if character == @character
|
39
|
+
|
40
|
+
@character.unlink(@)
|
41
|
+
@character.off('change:name', @onCharacterChangeName_, @)
|
42
|
+
@character = if character then character else Smalruby.FieldCharacter.NullCharacter
|
43
|
+
@character.link(@)
|
44
|
+
@character.on('change:name', @onCharacterChangeName_, @)
|
45
|
+
|
46
|
+
@setValue(@character.get('name'))
|
47
|
+
|
48
|
+
Smalruby.FieldCharacter.prototype.onCharacterSetAdd_ = (model, collection, options) ->
|
49
|
+
if @character == Smalruby.FieldCharacter.NullCharacter
|
50
|
+
@setCharacter(model)
|
51
|
+
|
52
|
+
Smalruby.FieldCharacter.prototype.onCharacterSetRemove_ = (model, collection, options) ->
|
53
|
+
if model == @character
|
54
|
+
@setCharacter()
|
55
|
+
|
56
|
+
Smalruby.FieldCharacter.prototype.onCharacterSetReset_ = (collection, options) ->
|
57
|
+
if @character == Smalruby.FieldCharacter.NullCharacter
|
58
|
+
@setCharacter(collection.first())
|
59
|
+
else
|
60
|
+
@setCharacter(collection.findWhere({ name: @getValue() }))
|
61
|
+
|
62
|
+
Smalruby.FieldCharacter.prototype.onCharacterChangeName_ = (model, value, options) ->
|
63
|
+
@setValue(value)
|
64
|
+
|
65
|
+
Smalruby.FieldCharacter.prototype.clone = ->
|
66
|
+
new Smalruby.FieldCharacter(@character, @changeHandler_)
|
67
|
+
|
68
|
+
Smalruby.FieldCharacter.prototype.dispose = ->
|
69
|
+
charSet = Smalruby.Collections.CharacterSet
|
70
|
+
charSet.off('add', @onCharacterSetAdd_, @)
|
71
|
+
charSet.off('remove', @onCharacterSetRemove_, @)
|
72
|
+
charSet.off('reset', @onCharacterSetReset_, @)
|
73
|
+
@setCharacter()
|
74
|
+
|
75
|
+
Blockly.FieldDropdown.prototype.dispose.call(@)
|
76
|
+
|
77
|
+
Smalruby.FieldCharacter.prototype.setText = (value) ->
|
78
|
+
# HACK: XMLをロードしたときにキャラクターとリンクさせる
|
79
|
+
unless @character
|
80
|
+
@character = Smalruby.FieldCharacter.NullCharacter
|
81
|
+
charSet = Smalruby.Collections.CharacterSet
|
82
|
+
@setCharacter(charSet.findWhere({ name: value }))
|
83
|
+
Blockly.FieldDropdown.prototype.setText.call(@, value)
|
84
|
+
|
85
|
+
Smalruby.FieldCharacter.dropdownCreate = ->
|
86
|
+
charSet = Smalruby.Collections.CharacterSet
|
87
|
+
if charSet.length > 0
|
88
|
+
Smalruby.Collections.CharacterSet.map (c) ->
|
89
|
+
n = c.get('name')
|
90
|
+
[n, n]
|
91
|
+
else
|
92
|
+
[[Smalruby.FieldCharacter.NullCharacter.get('name'), '']]
|
93
|
+
|
94
|
+
Smalruby.FieldCharacter.dropdownChange = (value) ->
|
95
|
+
c = Smalruby.Collections.CharacterSet.findWhere({ name: value })
|
96
|
+
if c
|
97
|
+
@setCharacter(c)
|
98
|
+
value
|
99
|
+
else
|
100
|
+
null
|
101
|
+
|
102
|
+
Smalruby.FieldCharacter.NullCharacter =
|
103
|
+
get: (name) ->
|
104
|
+
'キャラクターなし'
|
105
|
+
on: -> $.noop
|
106
|
+
off: -> $.noop
|
107
|
+
link: -> $.noop
|
108
|
+
unlink: -> $.noop
|
@@ -9,12 +9,16 @@
|
|
9
9
|
window.SmalrubyEditor.Hardware =
|
10
10
|
Type: 'Arduino' # 種別
|
11
11
|
DioPins: [2..13] # デジタルIOピン
|
12
|
+
PwmPins: [3, 5, 6, 9, 10, 11] # デジタルIOピンのうちPWMに対応しているピン
|
12
13
|
AiPins: [0..5] # アナログ入力ピン
|
13
14
|
|
14
15
|
dioPinDropdown =
|
15
16
|
(["D#{n}", "D#{n}"] for n in window.SmalrubyEditor.Hardware.DioPins)
|
16
17
|
|
17
18
|
pwmPinDropdown =
|
19
|
+
(["D#{n}", "D#{n}"] for n in window.SmalrubyEditor.Hardware.PwmPins)
|
20
|
+
|
21
|
+
rgbLedPinDropdown =
|
18
22
|
(["D#{n}", "D#{n}"] for n in [3, 9])
|
19
23
|
|
20
24
|
aiPinDropdown =
|
@@ -81,7 +85,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
81
85
|
.appendField('RGB LED')
|
82
86
|
.appendField(new Blockly.FieldDropdown(acDropdown), 'AC')
|
83
87
|
.appendField('コモン')
|
84
|
-
.appendField(new Blockly.FieldDropdown(
|
88
|
+
.appendField(new Blockly.FieldDropdown(rgbLedPinDropdown), 'PIN')
|
85
89
|
.appendField('を')
|
86
90
|
.appendField(new Blockly.FieldColour('#ff0000'), 'COLOUR')
|
87
91
|
.appendField('にする')
|
@@ -109,7 +113,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
109
113
|
.appendField('RGB LED')
|
110
114
|
.appendField(new Blockly.FieldDropdown(acDropdown), 'AC')
|
111
115
|
.appendField('コモン')
|
112
|
-
.appendField(new Blockly.FieldDropdown(
|
116
|
+
.appendField(new Blockly.FieldDropdown(rgbLedPinDropdown), 'PIN')
|
113
117
|
.appendField('をオフにする')
|
114
118
|
@setPreviousStatement(true)
|
115
119
|
@setNextStatement(true)
|
@@ -209,6 +213,35 @@ Blockly.Blocks['<%= n %>'] =
|
|
209
213
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
210
214
|
"seven_segment_display.off\n"
|
211
215
|
|
216
|
+
# 「サーボ」サブジャンル
|
217
|
+
|
218
|
+
# 「サーボ[▼ピン]を( )度(5~180)にする」ブロック
|
219
|
+
<% n = "#{category}_servo_set_position" %>
|
220
|
+
Blockly.Blocks['<%= n %>'] =
|
221
|
+
init: ()->
|
222
|
+
@setHelpUrl('')
|
223
|
+
@setColour(<%= color %>)
|
224
|
+
@appendDummyInput()
|
225
|
+
.appendField('サーボ')
|
226
|
+
.appendField(new Blockly.FieldDropdown(pwmPinDropdown), 'PIN')
|
227
|
+
.appendField('を')
|
228
|
+
@appendValueInput('POS')
|
229
|
+
.setCheck('Number')
|
230
|
+
@appendDummyInput()
|
231
|
+
.appendField('度(5~180)にする')
|
232
|
+
@setInputsInline(true)
|
233
|
+
@setPreviousStatement(true)
|
234
|
+
@setNextStatement(true)
|
235
|
+
@setTooltip('')
|
236
|
+
|
237
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
238
|
+
pin = @getFieldValue('PIN') #p sensor("A0").value
|
239
|
+
#p sensor("A0").value.class
|
240
|
+
#p(sensor("A0").value / 6)
|
241
|
+
|
242
|
+
pos = Blockly.Ruby.valueToCode(@, 'POS', Blockly.Ruby.ORDER_FUNCTION_CALL) || '5'
|
243
|
+
Blockly.Ruby.characterMethodCall_("servo(#{Blockly.Ruby.quote_(pin)}).position = #{pos}")
|
244
|
+
|
212
245
|
# 「ボタン」サブジャンル
|
213
246
|
|
214
247
|
# 条件:ボタン[▼]を押している
|
@@ -90,14 +90,14 @@ Blockly.Blocks['<%= n %>'] =
|
|
90
90
|
@setHelpUrl('')
|
91
91
|
@setColour(<%= color %>)
|
92
92
|
@appendDummyInput()
|
93
|
-
.appendField(new
|
93
|
+
.appendField(new Smalruby.FieldCharacter(), 'CHAR')
|
94
94
|
.appendField('へ向ける')
|
95
95
|
@setPreviousStatement(true)
|
96
96
|
@setNextStatement(true)
|
97
97
|
@setTooltip('')
|
98
98
|
|
99
99
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
100
|
-
char =
|
100
|
+
char = @getFieldValue('CHAR')
|
101
101
|
Blockly.Ruby.characterMethodCall_('point_towards', char)
|
102
102
|
|
103
103
|
# x座標を( )、y座標を( )にする
|
@@ -144,14 +144,14 @@ Blockly.Blocks['<%= n %>'] =
|
|
144
144
|
@setHelpUrl('')
|
145
145
|
@setColour(<%= color %>)
|
146
146
|
@appendDummyInput()
|
147
|
-
.appendField(new
|
147
|
+
.appendField(new Smalruby.FieldCharacter(), 'CHAR')
|
148
148
|
.appendField('へ行く')
|
149
149
|
@setPreviousStatement(true)
|
150
150
|
@setNextStatement(true)
|
151
151
|
@setTooltip('')
|
152
152
|
|
153
153
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
154
|
-
|
154
|
+
char = @getFieldValue('CHAR')
|
155
155
|
"#{Blockly.Ruby.rn()}go_to(#{var0})\n"
|
156
156
|
|
157
157
|
# ( )秒でx座標を( )、y座標を( )に変える
|
@@ -11,11 +11,11 @@
|
|
11
11
|
# 変数:( ) / ( )
|
12
12
|
<%
|
13
13
|
[
|
14
|
-
['add', '+', 'ADDITIVE', '+'],
|
15
|
-
['minus', 'ー', 'ADDITIVE', '-'],
|
16
|
-
['multiply', '×', 'MULTIPLICATIVE', '*'],
|
17
|
-
['divide', '÷', 'MULTIPLICATIVE', '/'],
|
18
|
-
].each do |suffix, operator_label, order_suffix, operator|
|
14
|
+
['add', '+', 'ADDITIVE', '+', '0', '0'],
|
15
|
+
['minus', 'ー', 'ADDITIVE', '-', '0', '0'],
|
16
|
+
['multiply', '×', 'MULTIPLICATIVE', '*', '0', '0'],
|
17
|
+
['divide', '÷', 'MULTIPLICATIVE', '/', '0', '1'],
|
18
|
+
].each do |suffix, operator_label, order_suffix, operator, default_a, default_b|
|
19
19
|
n = "#{category}_#{suffix}"
|
20
20
|
%>
|
21
21
|
|
@@ -24,8 +24,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
24
24
|
@setHelpUrl('')
|
25
25
|
@setColour(<%= color %>)
|
26
26
|
@interpolateMsg('%1<%= operator_label %>%2',
|
27
|
-
|
28
|
-
|
27
|
+
['A', null, Blockly.ALIGN_RIGHT],
|
28
|
+
['B', null, Blockly.ALIGN_RIGHT],
|
29
29
|
Blockly.ALIGN_RIGHT)
|
30
30
|
@setInputsInline(true)
|
31
31
|
@setOutput(true, null)
|
@@ -33,8 +33,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
33
33
|
|
34
34
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
35
35
|
order = Blockly.Ruby.ORDER_<%= order_suffix %>
|
36
|
-
a = Blockly.Ruby.valueToCode(block, 'A', order) || '
|
37
|
-
b = Blockly.Ruby.valueToCode(block, 'B', order) || '
|
36
|
+
a = Blockly.Ruby.valueToCode(block, 'A', order) || '<%= default_a %>'
|
37
|
+
b = Blockly.Ruby.valueToCode(block, 'B', order) || '<%= default_b %>'
|
38
38
|
[a + ' <%= operator %> ' + b, order]
|
39
39
|
<% end %>
|
40
40
|
|
@@ -45,12 +45,12 @@ Blockly.Ruby['<%= n %>'] = (block) ->
|
|
45
45
|
# 条件:( ) > ( )
|
46
46
|
<%
|
47
47
|
[
|
48
|
-
['
|
49
|
-
['
|
50
|
-
['compare_eq', '=', '=='],
|
51
|
-
['
|
52
|
-
['
|
53
|
-
].each do |suffix, operator_label, operator|
|
48
|
+
['compare_lt', '<', '<', 'RELATIONAL'],
|
49
|
+
['compare_lte', '≦', '<=', 'RELATIONAL'],
|
50
|
+
['compare_eq', '=', '==', 'EQUALS'],
|
51
|
+
['compare_gte', '≧', '>=', 'RELATIONAL'],
|
52
|
+
['compare_gt', '>', '>', 'RELATIONAL'],
|
53
|
+
].each do |suffix, operator_label, operator, order_suffix|
|
54
54
|
n = "#{category}_#{suffix}"
|
55
55
|
%>
|
56
56
|
|
@@ -67,7 +67,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
67
67
|
@setTooltip('')
|
68
68
|
|
69
69
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
70
|
-
order = Blockly.Ruby.
|
70
|
+
order = Blockly.Ruby.ORDER_<%= order_suffix %>;
|
71
71
|
a = Blockly.Ruby.valueToCode(block, 'A', order) || '0'
|
72
72
|
b = Blockly.Ruby.valueToCode(block, 'B', order) || '0'
|
73
73
|
[a + ' <%= operator %> ' + b, order]
|
@@ -88,10 +88,9 @@ Blockly.Blocks['<%= n %>'] =
|
|
88
88
|
@setTooltip('')
|
89
89
|
|
90
90
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
91
|
-
|
92
|
-
|
93
|
-
b
|
94
|
-
["rand(#{a}..#{b})", order]
|
91
|
+
a = Blockly.Ruby.valueToCode(block, 'A', Blockly.Ruby.ORDER_RANGE) || '0'
|
92
|
+
b = Blockly.Ruby.valueToCode(block, 'B', Blockly.Ruby.ORDER_RANGE) || '0'
|
93
|
+
["rand(#{a}..#{b})", Blockly.Ruby.ORDER_FUNCTION_CALL]
|
95
94
|
|
96
95
|
# 条件:< > かつ < >
|
97
96
|
# 条件:< > または < >
|
@@ -136,11 +135,11 @@ Blockly.Blocks['<%= n %>'] =
|
|
136
135
|
@setTooltip('')
|
137
136
|
|
138
137
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
139
|
-
order = Blockly.Ruby.
|
138
|
+
order = Blockly.Ruby.ORDER_UNARY_SIGN
|
140
139
|
a = Blockly.Ruby.valueToCode(block, 'A', order) || 'true'
|
141
140
|
["!#{a}", order]
|
142
141
|
|
143
|
-
# 変数:( )の
|
142
|
+
# 変数:( )の( )番目
|
144
143
|
<% n = "#{category}_index_of" %>
|
145
144
|
Blockly.Blocks['<%= n %>'] =
|
146
145
|
init: ()->
|
@@ -155,12 +154,11 @@ Blockly.Blocks['<%= n %>'] =
|
|
155
154
|
@setTooltip('')
|
156
155
|
|
157
156
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
158
|
-
|
159
|
-
|
160
|
-
index
|
161
|
-
["#{a}[#{index}]", order]
|
157
|
+
a = Blockly.Ruby.valueToCode(block, 'A', Blockly.Ruby.ORDER_FUNCTION_CALL) || '""'
|
158
|
+
index = Blockly.Ruby.valueToCode(block, 'INDEX', Blockly.Ruby.ORDER_INDEX) || '0'
|
159
|
+
["#{a}[#{index}]", Blockly.Ruby.ORDER_FUNCTION_CALL]
|
162
160
|
|
163
|
-
# 変数:
|
161
|
+
# 変数:( )の長さ
|
164
162
|
<% n = "#{category}_length" %>
|
165
163
|
Blockly.Blocks['<%= n %>'] =
|
166
164
|
init: ()->
|
@@ -194,8 +192,8 @@ Blockly.Blocks['<%= n %>'] =
|
|
194
192
|
|
195
193
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
196
194
|
order = Blockly.Ruby.ORDER_MULTIPLICATIVE
|
197
|
-
a = Blockly.Ruby.valueToCode(block, 'A', order) || '
|
198
|
-
b = Blockly.Ruby.valueToCode(block, 'B', order) || '
|
195
|
+
a = Blockly.Ruby.valueToCode(block, 'A', order) || '1'
|
196
|
+
b = Blockly.Ruby.valueToCode(block, 'B', order) || '1'
|
199
197
|
["#{a} % #{b}", order]
|
200
198
|
|
201
199
|
# 変数:( )を丸める
|
@@ -98,14 +98,13 @@ Blockly.Blocks['<%= n %>'] =
|
|
98
98
|
@setHelpUrl('')
|
99
99
|
@setColour(<%= color %>)
|
100
100
|
@appendDummyInput()
|
101
|
-
.appendField(new
|
101
|
+
.appendField(new Smalruby.FieldCharacter(), 'CHAR')
|
102
102
|
.appendField('に触れた')
|
103
103
|
@setOutput(true, 'Boolean')
|
104
104
|
@setTooltip('')
|
105
105
|
|
106
106
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
107
|
-
char =
|
108
|
-
.getName(block.getFieldValue('CHAR'), Blockly.Variables.NAME_TYPE)
|
107
|
+
char = @getFieldValue('CHAR')
|
109
108
|
Blockly.Ruby.characterMethodCallInput_('hit?', char)
|
110
109
|
|
111
110
|
# [ ]と聞いて待つ
|
@@ -186,15 +185,14 @@ Blockly.Blocks['<%= n %>'] =
|
|
186
185
|
@setHelpUrl('')
|
187
186
|
@setColour(<%= color %>)
|
188
187
|
@appendDummyInput()
|
189
|
-
.appendField(new
|
188
|
+
.appendField(new Smalruby.FieldCharacter(), 'CHAR')
|
190
189
|
.appendField('の')
|
191
190
|
.appendField(new Blockly.FieldDropdown(dropdown), 'PROPERTY')
|
192
191
|
@setOutput(true, ['Number', 'String'])
|
193
192
|
@setTooltip('')
|
194
193
|
|
195
194
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
196
|
-
char =
|
197
|
-
.getName(block.getFieldValue('CHAR'), Blockly.Variables.NAME_TYPE)
|
195
|
+
char = @getFieldValue('CHAR')
|
198
196
|
property = @getFieldValue('PROPERTY')
|
199
197
|
c = Smalruby.Collections.CharacterSet.findWhere({ name: char })
|
200
198
|
Blockly.Ruby.characterMethodCallInput_(property, null, { object: c })
|
@@ -10,28 +10,30 @@ break elsif module retry unless __ENCODING__
|
|
10
10
|
case end next return until
|
11
11
|
'.split(/\s+/)
|
12
12
|
|
13
|
-
# TODO: 確認すること
|
14
13
|
Blockly.Ruby.ORDER_ATOMIC = 0 # 0 "" ...
|
15
14
|
Blockly.Ruby.ORDER_COLLECTION = 1 # tuples, lists, dictionaries
|
16
15
|
Blockly.Ruby.ORDER_STRING_CONVERSION = 1 # `expression...`
|
17
|
-
Blockly.Ruby.ORDER_MEMBER = 2
|
18
|
-
Blockly.Ruby.
|
19
|
-
Blockly.Ruby.
|
20
|
-
Blockly.Ruby.ORDER_UNARY_SIGN =
|
21
|
-
Blockly.Ruby.
|
22
|
-
Blockly.Ruby.
|
23
|
-
Blockly.Ruby.
|
24
|
-
Blockly.Ruby.
|
25
|
-
Blockly.Ruby.
|
26
|
-
Blockly.Ruby.
|
27
|
-
Blockly.Ruby.
|
28
|
-
Blockly.Ruby.
|
29
|
-
|
30
|
-
Blockly.Ruby.
|
31
|
-
Blockly.Ruby.ORDER_LOGICAL_AND =
|
32
|
-
Blockly.Ruby.ORDER_LOGICAL_OR =
|
33
|
-
Blockly.Ruby.
|
34
|
-
Blockly.Ruby.
|
16
|
+
Blockly.Ruby.ORDER_MEMBER = 2 # ::
|
17
|
+
Blockly.Ruby.ORDER_INDEX = 3 # []
|
18
|
+
Blockly.Ruby.ORDER_FUNCTION_CALL = 4 # ()
|
19
|
+
Blockly.Ruby.ORDER_UNARY_SIGN = 5 # +(単項) ! ~
|
20
|
+
Blockly.Ruby.ORDER_EXPONENTIATION = 6 # **
|
21
|
+
Blockly.Ruby.ORDER_UNARY_MINUS_SIGN = 7 # -(単項)
|
22
|
+
Blockly.Ruby.ORDER_MULTIPLICATIVE = 8 # * / %
|
23
|
+
Blockly.Ruby.ORDER_ADDITIVE = 9 # + -
|
24
|
+
Blockly.Ruby.ORDER_BITWISE_SHIFT = 10 # << >>
|
25
|
+
Blockly.Ruby.ORDER_BITWISE_AND = 11 # &
|
26
|
+
Blockly.Ruby.ORDER_BITWISE_XOR = 12 # ^
|
27
|
+
Blockly.Ruby.ORDER_BITWISE_OR = 12 # |
|
28
|
+
Blockly.Ruby.ORDER_RELATIONAL = 13 # > >= < <=
|
29
|
+
Blockly.Ruby.ORDER_EQUALS = 14 # <=> == === != =~ !~
|
30
|
+
Blockly.Ruby.ORDER_LOGICAL_AND = 15 # &&
|
31
|
+
Blockly.Ruby.ORDER_LOGICAL_OR = 16 # ||
|
32
|
+
Blockly.Ruby.ORDER_RANGE = 17 # .. ...
|
33
|
+
Blockly.Ruby.ORDER_CONDITIONAL = 18 # ?:(条件演算子)
|
34
|
+
Blockly.Ruby.ORDER_ASSIGNMENT = 19 # =(+=, -= ... )
|
35
|
+
Blockly.Ruby.ORDER_NOT = 20 # not
|
36
|
+
Blockly.Ruby.ORDER_AND_OR = 21 # and or
|
35
37
|
Blockly.Ruby.ORDER_NONE = 99 # (...)
|
36
38
|
|
37
39
|
Blockly.Ruby.INFINITE_LOOP_TRAP = null
|