Class: Bizside::StringIO
- Inherits:
-
StringIO
- Object
- StringIO
- Bizside::StringIO
- Defined in:
- lib/bizside/string_io.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
Returns the value of attribute base_dir.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#file_size ⇒ Object
Returns the value of attribute file_size.
-
#fullpath ⇒ Object
Returns the value of attribute fullpath.
-
#md5 ⇒ Object
Returns the value of attribute md5.
Instance Method Summary collapse
-
#initialize(string = '', mode = 'r+') ⇒ StringIO
constructor
A new instance of StringIO.
- #original_dirname ⇒ Object
- #original_filename ⇒ Object
- #relative_dirname ⇒ Object
Constructor Details
#initialize(string = '', mode = 'r+') ⇒ StringIO
Returns a new instance of StringIO.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bizside/string_io.rb', line 9 def initialize(string = '', mode = 'r+') super(string, mode) begin self.md5 = Digest::MD5.hexdigest(self.read) rescue #失敗しても何もしない。 ensure self.rewind end end |
Instance Attribute Details
#base_dir ⇒ Object
Returns the value of attribute base_dir.
3 4 5 |
# File 'lib/bizside/string_io.rb', line 3 def base_dir @base_dir end |
#content_type ⇒ Object
Returns the value of attribute content_type.
5 6 7 |
# File 'lib/bizside/string_io.rb', line 5 def content_type @content_type end |
#file_size ⇒ Object
Returns the value of attribute file_size.
6 7 8 |
# File 'lib/bizside/string_io.rb', line 6 def file_size @file_size end |
#fullpath ⇒ Object
Returns the value of attribute fullpath.
4 5 6 |
# File 'lib/bizside/string_io.rb', line 4 def fullpath @fullpath end |
#md5 ⇒ Object
Returns the value of attribute md5.
7 8 9 |
# File 'lib/bizside/string_io.rb', line 7 def md5 @md5 end |
Instance Method Details
#original_dirname ⇒ Object
24 25 26 |
# File 'lib/bizside/string_io.rb', line 24 def original_dirname fullpath ? File.dirname(fullpath) : '' end |
#original_filename ⇒ Object
20 21 22 |
# File 'lib/bizside/string_io.rb', line 20 def original_filename fullpath ? File.basename(fullpath) : '' end |
#relative_dirname ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/bizside/string_io.rb', line 28 def relative_dirname if fullpath relpath = fullpath.sub(/^#{Regexp.quote(base_dir)}/,'').sub(/^\//,'') File.dirname(relpath) == '.' ? '' : File.dirname(relpath) else '' end end |