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.

Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/demos/default.xml +1 -1
  3. data/app/assets/javascripts/application.js +1 -0
  4. data/app/assets/javascripts/blocks/blockly.js.coffee.erb +1 -1
  5. data/app/assets/javascripts/blocks/events.js.coffee.erb +2 -3
  6. data/app/assets/javascripts/blocks/field_character.js.coffee.erb +108 -0
  7. data/app/assets/javascripts/blocks/hardware.js.coffee.erb +35 -2
  8. data/app/assets/javascripts/blocks/motion.js.coffee.erb +4 -4
  9. data/app/assets/javascripts/blocks/operators.js.coffee.erb +27 -29
  10. data/app/assets/javascripts/blocks/sensing.js.coffee.erb +4 -6
  11. data/app/assets/javascripts/generators/ruby.js.coffee.erb +21 -19
  12. data/app/assets/javascripts/models/character.js.coffee +21 -0
  13. data/app/assets/javascripts/views/character_modal_view.js.coffee +24 -3
  14. data/app/views/editor/_character_modal.html.haml +1 -1
  15. data/app/views/editor/_toolbox.html.haml +7 -3
  16. data/lib/smalruby_editor/version.rb +1 -1
  17. data/public/assets/{application-0c2ae32cd8822cec7ba6e445e2501010.js → application-735e172a0df828da16d22f5d3c26671f.js} +294 -59
  18. data/public/assets/{application-0c2ae32cd8822cec7ba6e445e2501010.js.gz → application-735e172a0df828da16d22f5d3c26671f.js.gz} +0 -0
  19. data/public/assets/{default-7f438ebd7f8ab6ef65c5b9744786e57f.xml → default-5d1886100d7c8961e9962bbc4bb0c714.xml} +1 -1
  20. data/public/assets/manifest-1f254fa92a71ba4faad0f99136daeed8.json +1 -1
  21. data/spec/acceptance/block_mode/blocks/hardware/servo_set_position.feature +104 -0
  22. data/spec/acceptance/block_mode/blocks/operators/and_or.feature +61 -0
  23. data/spec/acceptance/block_mode/blocks/operators/four_arithmetic_and_compares.feature +85 -0
  24. data/spec/acceptance/block_mode/blocks/operators/index_of.feature +60 -0
  25. data/spec/acceptance/block_mode/blocks/operators/length.feature +52 -0
  26. data/spec/acceptance/block_mode/blocks/operators/math_method.feature +109 -0
  27. data/spec/acceptance/block_mode/blocks/operators/negate.feature +47 -0
  28. data/spec/acceptance/block_mode/blocks/operators/rand.feature +60 -0
  29. data/spec/acceptance/block_mode/blocks/operators/round.feature +52 -0
  30. data/spec/acceptance/block_mode/blocks/operators/true_false.feature +36 -0
  31. data/spec/acceptance/block_mode/blocks/ruby/expression.feature +36 -0
  32. data/spec/acceptance/block_mode/blocks/ruby/p.feature +34 -0
  33. data/spec/acceptance/block_mode/blocks/ruby/statement_comment.feature +25 -0
  34. data/spec/javascripts/models/character_spec.coffee +44 -5
  35. data/spec/steps/ace_steps.rb +9 -0
  36. data/spec/steps/block_mode_steps.rb +14 -0
  37. data/spec/steps/fix_turnip.rb +35 -0
  38. data/spec/steps/text_editor_steps.rb +1 -0
  39. data/spec/teaspoon_env.rb +1 -1
  40. data/spec/turnip_helper.rb +1 -0
  41. metadata +34 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9b7ce8a6a476da8786c1a602322fa000c5ccc57
4
- data.tar.gz: 572804b7f7cb1eeaa24c4a8984e23a00194a2184
3
+ metadata.gz: 20db57ce467ebe6941df084c8dcb09680189e490
4
+ data.tar.gz: 4f1bbcc5b25609c155b2838344ee79e5afc3f08c
5
5
  SHA512:
6
- metadata.gz: c3abb0a9316623e2274bb090affc81d10ed013ce596c8ec8e8e422e5956a3c8c66243ea7823618460b69c28e57e4b1962bedc53bcf221d00e1c522528d082316
7
- data.tar.gz: 82c3675e7002cb04e70aa21145f36130937201c72d97e70cc5767dd2a62cdbfe3b26a913941469cc6be4504a0744e72fb701233302c0869adc2b0805b8b2a04f
6
+ metadata.gz: 274bdb33cf8848860654c4989af58f96b0903b10e12fd9087d6ef77f1915d9f96e0a40173e638f6418047650f88f2e47fe79cbd1a6efdf33567fe4a99c4561b7
7
+ data.tar.gz: 59966ae04b1324d73a6795e45a878b1ae55c50a3789e64542ade4b62fa0a5b23d04c67fb91c1b73ef27b29cb81d441c5c54f3158142d6056775b5b5afb1da1a7
@@ -77,7 +77,7 @@
77
77
  <block type="control_loop">
78
78
  <statement name="DO">
79
79
  <block type="motion_point_towards_character">
80
- <field name="VAR">car1</field>
80
+ <field name="CHAR">car1</field>
81
81
  <next>
82
82
  <block type="motion_move" inline="true">
83
83
  <value name="STEP">
@@ -34,5 +34,6 @@
34
34
  //= require_tree ./routers
35
35
  //= require ./block_mode
36
36
  //= require_tree ./generators
37
+ //= require ./blocks/field_character
37
38
  //= require_tree ./blocks
38
39
  //= require ./ruby_mode
@@ -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.ORDER_UNARY_SIGN else Blockly.Ruby.ORDER_ATOMIC
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 Blockly.FieldVariable('car1'), 'CHAR') # TODO
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 = Blockly.Ruby.variableDB_
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(pwmPinDropdown), 'PIN')
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(pwmPinDropdown), 'PIN')
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 Blockly.FieldVariable('char1'), 'VAR')
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 = Blockly.Ruby.variableDB_.getName(block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE)
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 Blockly.FieldVariable('char1'), 'VAR')
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
- var0 = Blockly.Ruby.variableDB_.getName(block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE)
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
- ['A', null, Blockly.ALIGN_RIGHT],
28
- ['B', null, Blockly.ALIGN_RIGHT],
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) || '0'
37
- b = Blockly.Ruby.valueToCode(block, 'B', order) || '0'
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
- ['compare_gt', '<', '<'],
49
- ['compare_gte', '≦', '<='],
50
- ['compare_eq', '=', '=='],
51
- ['compare_lte', '≧', '>='],
52
- ['compare_lt', '>', '>'],
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.ORDER_RELATIONAL;
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
- order = Blockly.Ruby.ORDER_FUNCTION_CALL
92
- a = Blockly.Ruby.valueToCode(block, 'A', order) || '0'
93
- b = Blockly.Ruby.valueToCode(block, 'B', order) || '0'
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.ORDER_LOGICAL_NOT
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
- order = Blockly.Ruby.ORDER_FUNCTION_CALL
159
- a = Blockly.Ruby.valueToCode(block, 'A', order) || '""'
160
- index = Blockly.Ruby.valueToCode(block, 'INDEX', order) || '0'
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) || '5'
198
- b = Blockly.Ruby.valueToCode(block, 'B', order) || '2'
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 Blockly.FieldVariable('car1'), 'CHAR')
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 = Blockly.Ruby.variableDB_
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 Blockly.FieldVariable('car1'), 'CHAR')
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 = Blockly.Ruby.variableDB_
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.ORDER_FUNCTION_CALL = 2 # ()
19
- Blockly.Ruby.ORDER_EXPONENTIATION = 3 # **
20
- Blockly.Ruby.ORDER_UNARY_SIGN = 4 # + -
21
- Blockly.Ruby.ORDER_BITWISE_NOT = 4 # ~
22
- Blockly.Ruby.ORDER_MULTIPLICATIVE = 5 # * / // %
23
- Blockly.Ruby.ORDER_ADDITIVE = 6 # + -
24
- Blockly.Ruby.ORDER_BITWISE_SHIFT = 7 # << >>
25
- Blockly.Ruby.ORDER_BITWISE_AND = 8 # &
26
- Blockly.Ruby.ORDER_BITWISE_XOR = 9 # ^
27
- Blockly.Ruby.ORDER_BITWISE_OR = 10 # |
28
- Blockly.Ruby.ORDER_RELATIONAL = 11 # in, not in, is, is not,
29
- # <, <=, >, >=, <>, !=, ==
30
- Blockly.Ruby.ORDER_LOGICAL_NOT = 12 # not
31
- Blockly.Ruby.ORDER_LOGICAL_AND = 13 # and
32
- Blockly.Ruby.ORDER_LOGICAL_OR = 14 # or
33
- Blockly.Ruby.ORDER_CONDITIONAL = 15 # if else
34
- Blockly.Ruby.ORDER_LAMBDA = 16 # lambda
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