Sha256: 3f4ae7b22d1480ee4d8d49aa3967cba3110bcb83973d3cc15f3c8e0ce586270c

Contents?: true

Size: 531 Bytes

Versions: 1

Compression:

Stored size: 531 Bytes

Contents

# encoding: UTF-8
class String

  def with_superscript_characters
    self.gsub(/\^2\b/,"²").gsub(/\^3\b/,"³")
  end

  def without_superscript_characters
    self.gsub(/¹\b/,"").gsub(/²\b/,"^2").gsub(/³\b/,"^3")
  end
  
  def remove_underscores
    self.gsub("_"," ")
  end

  def words
    split(/\s+/)
  end

  def word_count
    words.size
  end

  def starts_with_number?
    (/\A([\d\s.,]+)/i).match(self) ? true : false
  end

  def to_quantity
    Quantify::Quantity.parse(self)
  end
  alias :to_q :to_quantity

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quantify-3.0.0 lib/quantify/core_extensions/string.rb