Module: EditorHelper

Defined in:
app/helpers/editor_helper.rb

Instance Method Summary collapse

Instance Method Details

#toolbox_character_field(name = 'VAR') ⇒ String

ツールボックスのブロックに対して、キャラクターの入力フィールドの値を設定する

Parameters:

  • name (String) (defaults to: 'VAR')

    名前

Returns:

  • (String)

    XML



7
8
9
# File 'app/helpers/editor_helper.rb', line 7

def toolbox_character_field(name = 'VAR')
  %(<field name="#{h name}">char1</field>).html_safe
end

#toolbox_key_field(name = 'KEY', value = 'K_SPACE') ⇒ String

ツールボックスのブロックに対して、キーの入力フィールドの値を設定する

Parameters:

  • name (String) (defaults to: 'KEY')

    名前

  • value (String) (defaults to: 'K_SPACE')

    キーの名前。K_SPACE、K_Aなど

Returns:

  • (String)

    XML



16
17
18
# File 'app/helpers/editor_helper.rb', line 16

def toolbox_key_field(name = 'KEY', value = 'K_SPACE')
  %(<field name="#{h name}">#{h value}</field>).html_safe
end

#toolbox_number_value(name, value = 0) ⇒ String

ツールボックスのブロックに対して、数値型の入力のブロックを設定する

Parameters:

  • name (String)

    入力値の名前

  • value (Numeric) (defaults to: 0)

    数値

Returns:

  • (String)

    XML



25
26
27
28
29
30
31
32
33
# File 'app/helpers/editor_helper.rb', line 25

def toolbox_number_value(name, value = 0)
  "    <value name=\"\#{h name}\">\n      <block type=\"math_number\">\n        <field name=\"NUM\">\#{h value.to_i}</field>\n      </block>\n    </value>\n  XML\nend\n".strip_heredoc.html_safe

#toolbox_text_value(name = 'TEXT', value = '') ⇒ String

ツールボックスのブロックに対して、テキスト型の入力のブロックを設定する

Parameters:

  • name (String) (defaults to: 'TEXT')

    入力値の名前

  • value (String) (defaults to: '')

    文字列

Returns:

  • (String)

    XML



40
41
42
43
44
45
46
47
48
# File 'app/helpers/editor_helper.rb', line 40

def toolbox_text_value(name = 'TEXT', value = '')
  "    <value name=\"\#{h name}\">\n      <block type=\"text\">\n        <field name=\"TEXT\">\#{h value}</field>\n      </block>\n    </value>\n  XML\nend\n".strip_heredoc.html_safe