Sha256: 1a40ba558566580afccbcb5e211483f81757e780c843e507402d000e8809f1f6

Contents?: true

Size: 516 Bytes

Versions: 3

Compression:

Stored size: 516 Bytes

Contents

class BlocklyInterpreter::ExtensionBlocks::TextInflectBlock < BlocklyInterpreter::Block
  INFLECTIONS = %w(
    humanize
    pluralize
    singularize
    titleize
    camelize
    classify
    dasherize
    deconstantize
    demodulize
    parameterize
    tableize
    underscore
  )

  self.block_type = :text_inflect

  def value(execution_context)
    text = values['TEXT'].value(execution_context)

    case fields['OP']
    when *INFLECTIONS then text.public_send(fields['OP'])
    else text
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blockly_interpreter-0.3.0 lib/blockly_interpreter/extension_blocks/text_inflect_block.rb
blockly_interpreter-0.2.1 lib/blockly_interpreter/extension_blocks/text_inflect_block.rb
blockly_interpreter-0.2.0 lib/blockly_interpreter/extension_blocks/text_inflect_block.rb