Class: Reivt::Document
- Inherits:
-
Object
- Object
- Reivt::Document
- Defined in:
- lib/reivt/document.rb
Overview
Blueprint for Document objects
Instance Attribute Summary collapse
-
#blob ⇒ String
The contents of the file.
-
#content_type ⇒ String
The type of content within the file.
-
#doc_name ⇒ Array<DocumentClass>
The name of the file.
-
#has_diff ⇒ Boolean
Whether or not the file will have a diff.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Allows Documents objects to be compared using == using their contents and file name.
-
#eql?(other) ⇒ Boolean
Allows Documents objects to be compared using .eql? using their contents and file name.
-
#hash ⇒ Fixnum
Allows Documents objects to be compared using hashes created from a logical and (&) between the files contents and name.
-
#initialize(blob, content_type, doc_name, has_diff = false) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(blob, content_type, doc_name, has_diff = false) ⇒ Document
Returns a new instance of Document.
25 26 27 28 29 30 |
# 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 |
Instance Attribute Details
#blob ⇒ String
Returns The contents of the file.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/reivt/document.rb', line 22 class Document attr_accessor(:blob, :content_type, :doc_name, :name, :has_diff) 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 # 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 # def eql?(other) self == other end # 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 # def hash @blob.hash & @doc_name.hash end # 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 # def ==(other) @blob == other.blob && @doc_name == other.doc_name end end |
#content_type ⇒ String
Returns The type of content within the file.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/reivt/document.rb', line 22 class Document attr_accessor(:blob, :content_type, :doc_name, :name, :has_diff) 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 # 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 # def eql?(other) self == other end # 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 # def hash @blob.hash & @doc_name.hash end # 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 # def ==(other) @blob == other.blob && @doc_name == other.doc_name end end |
#doc_name ⇒ Array<DocumentClass>
Returns The name of the file.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/reivt/document.rb', line 22 class Document attr_accessor(:blob, :content_type, :doc_name, :name, :has_diff) 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 # 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 # def eql?(other) self == other end # 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 # def hash @blob.hash & @doc_name.hash end # 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 # def ==(other) @blob == other.blob && @doc_name == other.doc_name end end |
#has_diff ⇒ Boolean
Returns Whether or not the file will have a diff.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/reivt/document.rb', line 22 class Document attr_accessor(:blob, :content_type, :doc_name, :name, :has_diff) 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 # 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 # def eql?(other) self == other end # 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 # def hash @blob.hash & @doc_name.hash end # 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 # def ==(other) @blob == other.blob && @doc_name == other.doc_name end end |
#name ⇒ Object
Returns the value of attribute name.
23 24 25 |
# File 'lib/reivt/document.rb', line 23 def name @name end |
Instance Method Details
#==(other) ⇒ Boolean
Allows Documents objects to be compared using == using their contents
and file name.
63 64 65 |
# File 'lib/reivt/document.rb', line 63 def ==(other) @blob == other.blob && @doc_name == other.doc_name end |
#eql?(other) ⇒ Boolean
Allows Documents objects to be compared using .eql? using their contents
and file name.
40 41 42 |
# File 'lib/reivt/document.rb', line 40 def eql?(other) self == other end |
#hash ⇒ Fixnum
Allows Documents objects to be compared using hashes created from a
logical and (&) between the files contents and name.
51 52 53 |
# File 'lib/reivt/document.rb', line 51 def hash @blob.hash & @doc_name.hash end |