class Reivt::Document

Blueprint for Document objects

@author [brwnrclse]

@!attribute [rw] blob

@return [String] The contents of the file

@!attribute [rw] content_type

@return [String] The type of content within the file

@!attribute [rw] doc_name

@return [Array<DocumentClass>] The name of the file

@!attribute [rw] has_diff

@return [Boolean] Whether or not the file will have a diff

Attributes

blob[RW]
content_type[RW]
doc_name[RW]
has_diff[RW]
name[RW]

Public Class Methods

new(blob, content_type, doc_name, has_diff = false) click to toggle source
# File lib/reivt/document.rb, line 25
def initialize(blob, content_type, doc_name, has_diff = false)
  @blob = blob
  @content_type = content_type
  @has_diff = has_diff
  @doc_name = doc_name
end

Public Instance Methods

==(other) click to toggle source

Allows Documents objects to be compared using == using their contents

and file name.

@param other [Rev::Document] The Document to compare to

@return [Boolean] True if equal

False if not equa
# File lib/reivt/document.rb, line 63
def ==(other)
  @blob == other.blob && @doc_name == other.doc_name
end
eql?(other) click to toggle source

Allows Documents objects to be compared using .eql? using their contents

and file name.

@param other [Rev::Document] The Document to compare to

@return [Boolean] True if equal

False if not equa
# File lib/reivt/document.rb, line 40
def eql?(other)
  self == other
end
hash() click to toggle source

Allows Documents objects to be compared using hashes created from a

logical and (&) between the files contents and name.

@param other [Rev::Document] The Document to compare to

@return [Fixnum] The & between file content and name

# File lib/reivt/document.rb, line 51
def hash
  @blob.hash & @doc_name.hash
end