Class: BBFS::ContentData::Content
- Inherits:
-
Object
- Object
- BBFS::ContentData::Content
- Defined in:
- lib/content_data/content_data.rb
Instance Attribute Summary collapse
-
#checksum ⇒ Object
readonly
Returns the value of attribute checksum.
-
#first_appearance_time ⇒ Object
readonly
Returns the value of attribute first_appearance_time.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(checksum, size, first_appearance_time, content_serializer = nil) ⇒ Content
constructor
A new instance of Content.
- #to_s ⇒ Object
Constructor Details
#initialize(checksum, size, first_appearance_time, content_serializer = nil) ⇒ Content
Returns a new instance of Content.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/content_data/content_data.rb', line 11 def initialize(checksum, size, first_appearance_time, content_serializer = nil) if content_serializer != nil if (content_serializer.checksum == nil) raise ArgumentError.new("checksum have to be defined") else @checksum = content_serializer.checksum end if (content_serializer.size == nil) raise ArgumentError.new("size have to be defined") else @size = content_serializer.size end if (content_serializer.first_appearance_time == nil) raise ArgumentError.new("first_appearance_time have to be defined") else @first_appearance_time = ContentData.parse_time(content_serializer.first_appearance_time) end else @checksum = checksum @size = size @first_appearance_time = first_appearance_time end end |
Instance Attribute Details
#checksum ⇒ Object (readonly)
Returns the value of attribute checksum.
9 10 11 |
# File 'lib/content_data/content_data.rb', line 9 def checksum @checksum end |
#first_appearance_time ⇒ Object (readonly)
Returns the value of attribute first_appearance_time.
9 10 11 |
# File 'lib/content_data/content_data.rb', line 9 def first_appearance_time @first_appearance_time end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'lib/content_data/content_data.rb', line 9 def size @size end |
Instance Method Details
#==(other) ⇒ Object
40 41 42 43 44 |
# File 'lib/content_data/content_data.rb', line 40 def ==(other) return (self.checksum.eql? other.checksum and self.size.eql? other.size and self.first_appearance_time.to_i.eql? other.first_appearance_time.to_i) end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/content_data/content_data.rb', line 36 def to_s "%s,%d,%s" % [@checksum, @size, ContentData.format_time(@first_appearance_time)] end |