Sha256: 38783aafc6ffc309803b0bfda5a2daf05afe9f72eb7254d01ad935ec6b647619
Contents?: true
Size: 1021 Bytes
Versions: 7
Compression:
Stored size: 1021 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#{Unit::NUMBER_REGEX}/i).match(self) ? true : false end def starts_with_valid_unit_term? return false unless term = /\A#{Unit.unit_label_regex}#{Unit::INDEX_REGEX}?/.match(self) || /\A#{Unit.unit_symbol_regex}#{Unit::INDEX_REGEX}?/.match(self) || /\A#{Unit.unit_name_regex}#{Unit::INDEX_REGEX}?/.match(self) || /\A#{Unit::UNIT_DENOMINATOR_REGEX}/.match(self) || /\A(#{Unit::UNIT_PREFIX_TERMS_REGEX}|#{Unit::UNIT_SUFFIX_TERMS_REGEX})/i.match(self) return term[0] end def to_quantity Quantify::Quantity.parse(self) end alias :to_q :to_quantity end
Version data entries
7 entries across 7 versions & 1 rubygems