Class: BBFS::ContentData::Content

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#checksumObject (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_timeObject (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

#sizeObject (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_sObject



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