Class: Bitcoin::Grpc::EventsResponseEnum

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin/grpc/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ EventsResponseEnum

Returns a new instance of EventsResponseEnum.



131
132
133
134
# File 'lib/bitcoin/grpc/server.rb', line 131

def initialize(events)
  @events = events
  @logger = Bitcoin::Logger.create(:debug)
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



129
130
131
# File 'lib/bitcoin/grpc/server.rb', line 129

def events
  @events
end

#loggerObject (readonly)

Returns the value of attribute logger.



129
130
131
# File 'lib/bitcoin/grpc/server.rb', line 129

def logger
  @logger
end

Instance Method Details

#eachObject



136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/bitcoin/grpc/server.rb', line 136

def each
  return enum_for(:each) unless block_given?
  loop do
    event = events.shift
    if event
      response = Bitcoin::Grpc::EventsResponse.new
      field = event.class.name.split('::').last.snake
      response[field] = event
      yield response
    else
      sleep(1)
    end
  end
end