Class: BBFS::ContentData::ContentInstance

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(checksum, size, server_name, device, full_path, modification_time, content_instance_serializer = nil) ⇒ ContentInstance

Returns a new instance of ContentInstance.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/content_data/content_data.rb', line 50

def initialize(checksum, size, server_name, device, full_path, modification_time, content_instance_serializer = nil)
  if content_instance_serializer != nil
    if (content_instance_serializer.checksum == nil)
      raise ArgumentError.new("checksum have to be defined")
    else
      @checksum = content_instance_serializer.checksum
    end
    if (content_instance_serializer.size == nil)
      raise ArgumentError.new("size have to be defined")
    else
      @size = content_instance_serializer.size
    end
    if (content_instance_serializer.modification_time == nil)
      raise ArgumentError.new("modification_time have to be defined")
    else
      @modification_time = ContentData.parse_time(content_instance_serializer.modification_time)
    end
    if (content_instance_serializer.server_name == nil)
      raise ArgumentError.new("server_name have to be defined")
    else
      @server_name = content_instance_serializer.server_name
    end
    if (content_instance_serializer.device == nil)
      raise ArgumentError.new("device have to be defined")
    else
      @device = content_instance_serializer.device
    end
    if (content_instance_serializer.full_path == nil)
      raise ArgumentError.new("full_path have to be defined")
    else
      @full_path = content_instance_serializer.full_path
    end
  else
    @checksum = checksum
    @size = size
    @server_name = server_name
    @device = device
    @full_path = full_path
    @modification_time = modification_time
  end
end

Instance Attribute Details

#checksumObject (readonly)

Returns the value of attribute checksum.



48
49
50
# File 'lib/content_data/content_data.rb', line 48

def checksum
  @checksum
end

#deviceObject (readonly)

Returns the value of attribute device.



48
49
50
# File 'lib/content_data/content_data.rb', line 48

def device
  @device
end

#full_pathObject (readonly)

Returns the value of attribute full_path.



48
49
50
# File 'lib/content_data/content_data.rb', line 48

def full_path
  @full_path
end

#modification_timeObject (readonly)

Returns the value of attribute modification_time.



48
49
50
# File 'lib/content_data/content_data.rb', line 48

def modification_time
  @modification_time
end

#server_nameObject (readonly)

Returns the value of attribute server_name.



48
49
50
# File 'lib/content_data/content_data.rb', line 48

def server_name
  @server_name
end

#sizeObject (readonly)

Returns the value of attribute size.



48
49
50
# File 'lib/content_data/content_data.rb', line 48

def size
  @size
end

Class Method Details

.instance_global_path(server_name, full_path) ⇒ Object



96
97
98
# File 'lib/content_data/content_data.rb', line 96

def ContentInstance.instance_global_path(server_name, full_path)
  "%s:%s" % [server_name, full_path]
end

Instance Method Details

#==(other) ⇒ Object



105
106
107
108
109
110
111
112
# File 'lib/content_data/content_data.rb', line 105

def ==(other)
  return (self.checksum.eql? other.checksum and
      self.size.eql? other.size and
      self.server_name.eql? other.server_name and
      self.device.eql? other.device and
      self.full_path.eql? other.full_path and
      self.modification_time.to_i.eql? other.modification_time.to_i)
end

#global_pathObject



92
93
94
# File 'lib/content_data/content_data.rb', line 92

def global_path
  ContentInstance.instance_global_path(@server_name, @full_path)
end

#to_sObject



100
101
102
103
# File 'lib/content_data/content_data.rb', line 100

def to_s
  "%s,%d,%s,%s,%s,%s" % [@checksum, @size, @server_name,
                         @device, @full_path, ContentData.format_time(@modification_time)]
end