Class: Temper::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/temper.rb

Direct Known Subclasses

File, StringIO

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.

Raises:

  • (RuntimeException)


10
11
12
13
14
# File 'lib/temper.rb', line 10

def initialize(options = {})
  raise RuntimeException, "No @storage set" unless @storage
  self.original_filename = options[:original_filename] || ::File.basename(path)
  self.content_type = infer_content_type || "text/plain"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object

:nodoc:



24
25
26
# File 'lib/temper.rb', line 24

def method_missing(method_name, *args, &block) #:nodoc:
  @storage.__send__(method_name, *args, &block)
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



8
9
10
# File 'lib/temper.rb', line 8

def content_type
  @content_type
end

#original_filenameObject

Returns the value of attribute original_filename.



7
8
9
# File 'lib/temper.rb', line 7

def original_filename
  @original_filename
end

Instance Method Details

#fingerprintObject



16
17
18
# File 'lib/temper.rb', line 16

def fingerprint
  @fingerprint ||= Digest::MD5.hexdigest(self.read)
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/temper.rb', line 20

def respond_to?(*args)
  super or @storage.respond_to?(*args)
end