Module: StringHelper
- Included in:
- String
- Defined in:
- lib/rubyhelper/stringhelper.rb
Instance Method Summary collapse
-
#^(k) ⇒ Object
CRYXOR.
-
#sha2 ⇒ Object
SHA2.
-
#static(n, char = ' ') ⇒ Object
STATIC.
- #to_f ⇒ Object
-
#to_i_wd(char = ' ') ⇒ Object
To_i with delimiter.
- #to_plain ⇒ Object
-
#to_t ⇒ Object
Returns true or false.
Instance Method Details
#^(k) ⇒ Object
CRYXOR
25 26 27 28 29 30 31 |
# File 'lib/rubyhelper/stringhelper.rb', line 25 def ^(k) str = "" self.size.times do |i| str << (self[i].ord ^ k[i % k.size].ord).chr end return str end |
#sha2 ⇒ Object
SHA2
34 35 36 |
# File 'lib/rubyhelper/stringhelper.rb', line 34 def sha2 Digest::SHA2.hexdigest(self) end |
#static(n, char = ' ') ⇒ Object
STATIC
39 40 41 42 43 44 45 |
# File 'lib/rubyhelper/stringhelper.rb', line 39 def static(n, char=' ') if self.size < n return self + char * (n - self.size).to_i else return self[0...n] end end |
#to_f ⇒ Object
14 15 16 17 |
# File 'lib/rubyhelper/stringhelper.rb', line 14 def to_f self.gsub!(',', '.') super end |
#to_i_wd(char = ' ') ⇒ Object
To_i with delimiter
20 21 22 |
# File 'lib/rubyhelper/stringhelper.rb', line 20 def to_i_wd(char=' ') self.delete(char.to_s).to_i end |
#to_plain ⇒ Object
8 9 10 11 12 |
# File 'lib/rubyhelper/stringhelper.rb', line 8 def to_plain self.tr( "ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž", "AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz") end |
#to_t ⇒ Object
Returns true or false
48 49 50 51 52 53 54 |
# File 'lib/rubyhelper/stringhelper.rb', line 48 def to_t if self == "true" return true else return false end end |