Sha256: f4635fd950749a32a2c234253ce68b5fdc6eaaac11ba33f92b25651e2d6fe80d

Contents?: true

Size: 710 Bytes

Versions: 39

Compression:

Stored size: 710 Bytes

Contents

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 pluralize
    # TODO: Temp implementation
    if self[-1] != 's'
      return self + 's'
    else
      return self
    end
  end
  
  def singularize
    # TODO: Temp implementation
    if self[-1] == 's'
      return self[0..-2]
    else
      return self
    end
  end
  
  def plural?
    # TODO: Temp implementation
    self[-1] == 's'
  end
  
  def singular?
    # TODO: Temp implementation
    self[-1] != 's'
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
volt-0.6.5 lib/volt/extra_core/string.rb
volt-0.6.4 lib/volt/extra_core/string.rb
volt-0.6.3 lib/volt/extra_core/string.rb
volt-0.6.2 lib/volt/extra_core/string.rb
volt-0.6.1 lib/volt/extra_core/string.rb
volt-0.6.0 lib/volt/extra_core/string.rb
volt-0.5.18 lib/volt/extra_core/string.rb
volt-0.5.17 lib/volt/extra_core/string.rb
volt-0.5.16 lib/volt/extra_core/string.rb
volt-0.5.15 lib/volt/extra_core/string.rb
volt-0.5.14 lib/volt/extra_core/string.rb
volt-0.5.13 lib/volt/extra_core/string.rb
volt-0.5.12 lib/volt/extra_core/string.rb
volt-0.5.11 lib/volt/extra_core/string.rb
volt-0.5.10 lib/volt/extra_core/string.rb
volt-0.5.9 lib/volt/extra_core/string.rb
volt-0.5.8 lib/volt/extra_core/string.rb
volt-0.5.7 lib/volt/extra_core/string.rb
volt-0.5.6 lib/volt/extra_core/string.rb
volt-0.5.4 lib/volt/extra_core/string.rb