Class: Rack::MogileFS::Endpoint::File

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/mogilefs/endpoint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, data) ⇒ File

Returns a new instance of File.



15
16
17
# File 'lib/rack/mogilefs/endpoint.rb', line 15

def initialize(path, data)
  @path, @data = path, data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



13
14
15
# File 'lib/rack/mogilefs/endpoint.rb', line 13

def data
  @data
end

#pathObject

Returns the value of attribute path.



13
14
15
# File 'lib/rack/mogilefs/endpoint.rb', line 13

def path
  @path
end

Instance Method Details

#content_type(default = nil) ⇒ Object



27
28
29
# File 'lib/rack/mogilefs/endpoint.rb', line 27

def content_type(default=nil)
  Mime.mime_type(extname, default)
end

#extnameObject



19
20
21
# File 'lib/rack/mogilefs/endpoint.rb', line 19

def extname
  ::File.extname(@path)
end

#lengthObject



23
24
25
# File 'lib/rack/mogilefs/endpoint.rb', line 23

def length
  Utils.bytesize(@data).to_s
end