Class: Firecracker::Base

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

Direct Known Subclasses

TCPScraper, UDPScraper

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Base

Example:

{
  tracker: "tracker.ccc.de",
  hashes: ["2bbf3d63e6b313ecf2655067b51e93f17eeeb135"],
  debug: false
}


15
16
17
18
19
20
21
22
# File 'lib/firecracker/base.rb', line 15

def initialize(args = {})
  @options = {
    debug: false,
    timeout: 2,
    tracker: nil,
    hashes: []
  }.merge(args)
end

Instance Method Details

#debug?Boolean

Returns Should we print debug ouput?.

Returns:

  • (Boolean)

    Should we print debug ouput?



38
39
40
# File 'lib/firecracker/base.rb', line 38

def debug?
  @options[:debug]
end

#hashesObject



45
46
47
# File 'lib/firecracker/base.rb', line 45

def hashes
  @options[:hashes]
end

#timeoutObject

Returns Integer Global timeout limit.

Returns:

  • Integer Global timeout limit



52
53
54
# File 'lib/firecracker/base.rb', line 52

def timeout
  @options[:timeout]
end

#valid?Boolean

Returns Do we have everyting that’s needed to do the request.

Returns:

  • (Boolean)

    Do we have everyting that’s needed to do the request.



28
29
30
31
32
33
# File 'lib/firecracker/base.rb', line 28

def valid?
  [
    @options[:tracker],
    @options[:hashes].count.between?(1, 72)
  ].all?
end