Sha256: 72663d87dbfe26003a50298994aefe245feb0f58955ff4c491228cb2f122da89
Contents?: true
Size: 811 Bytes
Versions: 2
Compression:
Stored size: 811 Bytes
Contents
module Typeright # Numbers and symbols replacement module Calculator class << self def work(txt) math(arrows(txt)) end def arrows(txt) txt .gsub(/(^|\s)\=\>(\W)/, '\1⇒\2') .gsub(/(^|\s)-\>(\W)/, '\1→\2') .gsub(/(^|\s)\<-(\W)/, '\1←\2') .gsub(/(^|\s)\<\=(\W)/, '\1⇐\2') .gsub(/(^|\s)\<\<(\w)/, '\1«\2') .gsub(/(\w)\>\>(\s|$)/, '\1»\2') end # Maybe (1) -> ① ⨉× def math(txt) txt .gsub(/(^|\s)Pi(\W)/, '\1π\2') .gsub(/(\d\s)\/(\s\d)/, '\1÷\2') .gsub(/(\d\s)\*(\s\d)/, '\1×\2') .gsub(/(^|\s)\!\=(\W)/, '\1≠\2') .gsub(/(^|\s)\+-(\s)/, '\1±\2') .gsub(/(\w)%o(\s|$)/, '\1‰\2') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
typeright-0.0.5 | lib/typeright/calculator.rb |
typeright-0.0.3 | lib/typeright/calculator.rb |