Module: Noteshred::Tools
- Defined in:
- lib/noteshred/tools.rb
Class Method Summary collapse
Class Method Details
.decode_utf8(string) ⇒ Object
8 9 10 |
# File 'lib/noteshred/tools.rb', line 8 def self.decode_utf8(string) Base64.decode64(string.encode('ascii-8bit')).force_encoding('utf-8') end |
.encode_utf8(string) ⇒ Object
4 5 6 |
# File 'lib/noteshred/tools.rb', line 4 def self.encode_utf8(string) Base64.encode64(string).encode('utf-8') end |
.hashify(obj) ⇒ Object
12 13 14 15 16 |
# File 'lib/noteshred/tools.rb', line 12 def self.hashify(obj) obj.instance_variables.each_with_object({}) { |var, hsh| hsh[var.to_s.delete("@")] = obj.instance_variable_get(var) } end |