Class: KingKong::Runner::DSL::Pinger

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

Overview

Encapsulate the configuration of a bunch of pingers that we can run in one KingKong file

Defined Under Namespace

Modules: Unit

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blockObject

Returns the value of attribute block.



85
86
87
# File 'lib/kingkong/runner.rb', line 85

def block
  @block
end

Instance Method Details

#completed(&block) ⇒ Object

Callback when we’ve completed the configuration of this thing.



124
125
126
127
# File 'lib/kingkong/runner.rb', line 124

def completed(&block)
  @completed_blk = block
  self
end

#durationObject

The number of seconds the timer will wait between ticks. We’ll pass this into EM



114
115
116
# File 'lib/kingkong/runner.rb', line 114

def duration
  @units * @quantity
end

#every(quantity) ⇒ Object



87
88
89
90
# File 'lib/kingkong/runner.rb', line 87

def every(quantity)
  @quantity = quantity
  self
end

#hours(&block) ⇒ Object Also known as: hour

Configure the ping duration as hours



107
108
109
110
# File 'lib/kingkong/runner.rb', line 107

def hours(&block)
  unitize Unit::Hour, &block
  complete
end

#minutes(&block) ⇒ Object Also known as: minute

Configure the duration as minutes



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

def minutes(&block)
  unitize Unit::Minute, &block
  complete
end

#pingerObject

Return a configured instance of a pinger that we can fire up and do stuff with



119
120
121
# File 'lib/kingkong/runner.rb', line 119

def pinger
  KingKong::Pinger.new(duration, &@block)
end

#seconds(&block) ⇒ Object Also known as: second

Configure duration as seconds



93
94
95
96
# File 'lib/kingkong/runner.rb', line 93

def seconds(&block)
  unitize Unit::Second, &block
  complete
end