Sha256: 34f9727837bb2b64b92dcd8d5846dee3b67a648f21a0aa92720da17cfcabb99e

Contents?: true

Size: 725 Bytes

Versions: 9

Compression:

Stored size: 725 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 titleize
    self.gsub('_', ' ').split(' ').map {|w| w.capitalize }.join(' ')
  end

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
volt-0.8.8 lib/volt/extra_core/string.rb
volt-0.8.7 lib/volt/extra_core/string.rb
volt-0.8.6 lib/volt/extra_core/string.rb
volt-0.8.5 lib/volt/extra_core/string.rb
volt-0.8.4 lib/volt/extra_core/string.rb
volt-0.8.3 lib/volt/extra_core/string.rb
volt-0.8.2 lib/volt/extra_core/string.rb
volt-0.8.1 lib/volt/extra_core/string.rb
volt-0.8.0 lib/volt/extra_core/string.rb