Class: Junziqian::Tool::AttacheUtils
- Inherits:
-
Object
- Object
- Junziqian::Tool::AttacheUtils
- Defined in:
- lib/junziqian/tool/attache_utils.rb
Instance Method Summary collapse
- #file_name ⇒ Object
- #file_type ⇒ Object
-
#initialize(file_path) ⇒ AttacheUtils
constructor
A new instance of AttacheUtils.
- #uploadStr ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(file_path) ⇒ AttacheUtils
Returns a new instance of AttacheUtils.
5 6 7 |
# File 'lib/junziqian/tool/attache_utils.rb', line 5 def initialize file_path @file_path = file_path end |
Instance Method Details
#file_name ⇒ Object
18 19 20 |
# File 'lib/junziqian/tool/attache_utils.rb', line 18 def file_name @file_path.match(/([^\/]+\.([a-z]+))$/)[0] end |
#file_type ⇒ Object
9 10 11 12 |
# File 'lib/junziqian/tool/attache_utils.rb', line 9 def file_type match_data = @file_path.match(/\.([a-z]+)$/) match_data ? match_data[1] : '' end |
#uploadStr ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/junziqian/tool/attache_utils.rb', line 22 def uploadStr file =File.open(@file_path) b = file.readlines().join('') c = Base64.strict_encode64(file_name) +'@'+ Base64.strict_encode64(b) # array('+','/','='),array('-','_','') c.gsub('+', '-').gsub('/','_').gsub('=','') end |
#value ⇒ Object
14 15 16 |
# File 'lib/junziqian/tool/attache_utils.rb', line 14 def value @file_path end |