Class: Threatinator::EventBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feed) ⇒ EventBuilder

Returns a new instance of EventBuilder.



6
7
8
9
10
# File 'lib/threatinator/event_builder.rb', line 6

def initialize(feed)
  @feed = feed
  @built_events = []
  @total = 0
end

Instance Attribute Details

#totalObject (readonly)

Returns the value of attribute total.



5
6
7
# File 'lib/threatinator/event_builder.rb', line 5

def total
  @total
end

Instance Method Details

#clearObject



23
24
25
# File 'lib/threatinator/event_builder.rb', line 23

def clear
  @built_events.clear
end

#countObject



19
20
21
# File 'lib/threatinator/event_builder.rb', line 19

def count
  @built_events.count
end

#create_event {|event| ... } ⇒ Object

Yields:

  • (event)


31
32
33
34
35
36
37
38
# File 'lib/threatinator/event_builder.rb', line 31

def create_event
  event = Threatinator::Event.new
  event.feed_provider = @feed.provider
  event.feed_name = @feed.name
  yield(event)
  @total += 1
  @built_events << event
end

#create_event_procObject



27
28
29
# File 'lib/threatinator/event_builder.rb', line 27

def create_event_proc
  self.method(:create_event).to_proc
end

#each_built_eventObject



12
13
14
15
16
17
# File 'lib/threatinator/event_builder.rb', line 12

def each_built_event
  @built_events.each do |event|
    yield event
  end
  @built_events.clear
end