Class: Virginia::DocumentCache::Document

Inherits:
Struct
  • Object
show all
Defined in:
lib/virginia/document_cache/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, body, content_type = 'text/plain', lifetime = nil) ⇒ Document

Returns a new instance of Document.



6
7
8
9
10
11
12
# File 'lib/virginia/document_cache/document.rb', line 6

def initialize(id, body, content_type = 'text/plain', lifetime = nil)
  self.id, self.body, self.content_type, self.lifetime = id, body, content_type, lifetime
  self.created_at = Time.now
  if self.lifetime
    self.expires_at = self.created_at + self.lifetime
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



5
6
7
# File 'lib/virginia/document_cache/document.rb', line 5

def body
  @body
end

#content_typeObject

Returns the value of attribute content_type

Returns:

  • (Object)

    the current value of content_type



5
6
7
# File 'lib/virginia/document_cache/document.rb', line 5

def content_type
  @content_type
end

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



5
6
7
# File 'lib/virginia/document_cache/document.rb', line 5

def created_at
  @created_at
end

#expires_atObject

Returns the value of attribute expires_at

Returns:

  • (Object)

    the current value of expires_at



5
6
7
# File 'lib/virginia/document_cache/document.rb', line 5

def expires_at
  @expires_at
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



5
6
7
# File 'lib/virginia/document_cache/document.rb', line 5

def id
  @id
end

#lifetimeObject

Returns the value of attribute lifetime

Returns:

  • (Object)

    the current value of lifetime



5
6
7
# File 'lib/virginia/document_cache/document.rb', line 5

def lifetime
  @lifetime
end