Class: Metalink4FileHash

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

Overview

Because hash can’t just be a string. We need to specify what type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Metalink4FileHash

Returns a new instance of Metalink4FileHash.



18
19
20
21
22
23
24
# File 'lib/metalink4.rb', line 18

def initialize(opts = {})
  opts = opts.inject({}){ |r, (k,v)| r[k.to_sym] = v; r }
  
  self.hash_value = opts.fetch(:hash_value, nil)
  self.hash_type = opts.fetch(:hash_type, nil)
  self.piece = opts.fetch(:piece, nil)
end

Instance Attribute Details

#hash_typeObject

Returns the value of attribute hash_type.



14
15
16
# File 'lib/metalink4.rb', line 14

def hash_type
  @hash_type
end

#hash_valueObject

Returns the value of attribute hash_value.



14
15
16
# File 'lib/metalink4.rb', line 14

def hash_value
  @hash_value
end

#pieceObject

Returns the value of attribute piece.



14
15
16
# File 'lib/metalink4.rb', line 14

def piece
  @piece
end