Sha256: 3ac51e0b57765c5ee8fa94507fe50a9147e9352e2fff956d9a19d0721022f2ff

Contents?: true

Size: 1.93 KB

Versions: 30

Compression:

Stored size: 1.93 KB

Contents

# 「Ruby」ジャンル

<%
  category = 'ruby'
  require 'smalruby_editor'
  require 'smalruby_editor/blockly_message_helper'
  color = SmalrubyEditor::COLORS[category.to_sym]
%>

# 文
<% n = "#{category}_statement" %>
Blockly.Blocks['<%= n %>'] =
  init: ()->
    @setHelpUrl('')
    @setColour(<%= color %>)
    @appendDummyInput()
      .appendField(<%= bm('.statement') %>)
      .appendField(new Blockly.FieldTextInput(''), 'STATEMENT')
    @setPreviousStatement(true)
    @setNextStatement(true)
    @setTooltip('')

Blockly.Ruby['<%= n %>'] = (block) ->
  statement = @getFieldValue('STATEMENT')
  "#{statement}\n"

# 式
<% n = "#{category}_expression" %>
Blockly.Blocks['<%= n %>'] =
  init: ()->
    @setHelpUrl('')
    @setColour(<%= color %>)
    @appendDummyInput()
      .appendField(<%= bm('.expression') %>)
      .appendField(new Blockly.FieldTextInput(''), 'EXP')
    @setOutput(true, null)
    @setTooltip('')

Blockly.Ruby['<%= n %>'] = (block) ->
  exp = @getFieldValue('EXP')
  ["(#{exp})", Blockly.Ruby.ORDER_ATOMIC]

# コメント
<% n = "#{category}_comment" %>
Blockly.Blocks['<%= n %>'] =
  init: ()->
    @setHelpUrl('')
    @setColour(<%= color %>)
    @appendDummyInput()
      .appendField(<%= bm('.comment') %>)
      .appendField(new Blockly.FieldTextInput(''), 'COMMENT')
    @setPreviousStatement(true)
    @setNextStatement(true)
    @setTooltip('')

Blockly.Ruby['<%= n %>'] = (block) ->
  comment = @getFieldValue('COMMENT')
  "# #{comment}\n"

# p
<% n = "#{category}_p" %>
Blockly.Blocks['<%= n %>'] =
  init: ()->
    @setHelpUrl('')
    @setColour(<%= color %>)
    @interpolateMsg(<%= bm('.p') %>,
                    ['ARG', null, Blockly.ALIGN_RIGHT],
                    Blockly.ALIGN_RIGHT)
    @setInputsInline(true)
    @setPreviousStatement(true)
    @setNextStatement(true)
    @setTooltip('')

Blockly.Ruby['<%= n %>'] = (block) ->
  arg = Blockly.Ruby.valueToCode(@, 'ARG', Blockly.Ruby.ORDER_NONE) || '""'
  "p(#{arg})\n"

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
smalruby-editor-0.4.1-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.4.2-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.4.2 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.4.1 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.4.0-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.4.0 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.5-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.5 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.4-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.4 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.3-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.3 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.2-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.2 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.1-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.1 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.0-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.3.0 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.2.7-x86-mingw32 app/assets/javascripts/blocks/ruby.js.coffee.erb
smalruby-editor-0.2.7 app/assets/javascripts/blocks/ruby.js.coffee.erb