Class: Threatinator::EventBuilder
- Inherits:
-
Object
- Object
- Threatinator::EventBuilder
- Defined in:
- lib/threatinator/event_builder.rb
Instance Attribute Summary collapse
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #clear ⇒ Object
- #count ⇒ Object
- #create_event {|event| ... } ⇒ Object
- #create_event_proc ⇒ Object
- #each_built_event ⇒ Object
-
#initialize(feed) ⇒ EventBuilder
constructor
A new instance of EventBuilder.
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
#total ⇒ Object (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
#clear ⇒ Object
23 24 25 |
# File 'lib/threatinator/event_builder.rb', line 23 def clear @built_events.clear end |
#count ⇒ Object
19 20 21 |
# File 'lib/threatinator/event_builder.rb', line 19 def count @built_events.count end |
#create_event {|event| ... } ⇒ Object
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_proc ⇒ Object
27 28 29 |
# File 'lib/threatinator/event_builder.rb', line 27 def create_event_proc self.method(:create_event).to_proc end |
#each_built_event ⇒ Object
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 |