Sha256: a5bf6a5723b15fe9b825c7284a9a54d7244aec7238f499ae9591044e59804ef9

Contents?: true

Size: 634 Bytes

Versions: 21

Compression:

Stored size: 634 Bytes

Contents

require 'volt/extra_core/inflector'

class String
  # TODO: replace with better implementations
  # NOTE: strings are currently immutable in Opal, so no ! methods
  def camelize
    self.split("_").map {|s| s.capitalize }.join("")
  end

  def underscore
    self.scan(/[A-Z][a-z]*/).join("_").downcase
  end

  def dasherize
    self.gsub('_', '-')
  end

  def pluralize
    Inflector.pluralize(self)
  end

  def singularize
    Inflector.singularize(self)
  end

  def plural?
    # TODO: Temp implementation
    self.pluralize == self
  end

  def singular?
    # TODO: Temp implementation
    self.singularize == self
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
volt-0.7.23 lib/volt/extra_core/string.rb
volt-0.7.22 lib/volt/extra_core/string.rb
volt-0.7.21 lib/volt/extra_core/string.rb
volt-0.7.20 lib/volt/extra_core/string.rb
volt-0.7.19 lib/volt/extra_core/string.rb
volt-0.7.18 lib/volt/extra_core/string.rb
volt-0.7.17 lib/volt/extra_core/string.rb
volt-0.7.16 lib/volt/extra_core/string.rb
volt-0.7.15 lib/volt/extra_core/string.rb
volt-0.7.14 lib/volt/extra_core/string.rb
volt-0.7.13 lib/volt/extra_core/string.rb
volt-0.7.12 lib/volt/extra_core/string.rb
volt-0.7.10 lib/volt/extra_core/string.rb
volt-0.7.9 lib/volt/extra_core/string.rb
volt-0.7.8 lib/volt/extra_core/string.rb
volt-0.7.7 lib/volt/extra_core/string.rb
volt-0.7.6 lib/volt/extra_core/string.rb
volt-0.7.5 lib/volt/extra_core/string.rb
volt-0.7.4 lib/volt/extra_core/string.rb
volt-0.7.3 lib/volt/extra_core/string.rb