Class: Hexabat::Client
- Inherits:
-
Object
- Object
- Hexabat::Client
- Defined in:
- lib/hexabat/client.rb
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #import ⇒ Object
-
#initialize(repository, params = {}) ⇒ Client
constructor
A new instance of Client.
- #known_events ⇒ Object
- #on(event_callback) ⇒ Object
Constructor Details
#initialize(repository, params = {}) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 20 |
# File 'lib/hexabat/client.rb', line 12 def initialize(repository, params = {}) @repository = repository @params = params @callbacks = { issue_retrieved: ->(issue){}, issue_count_known: ->(issue_count){}, error: ->(repository, status, ) { STDERR.puts "#{repository} #{status} #{}" } } end |
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
10 11 12 |
# File 'lib/hexabat/client.rb', line 10 def callbacks @callbacks end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/hexabat/client.rb', line 10 def params @params end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
10 11 12 |
# File 'lib/hexabat/client.rb', line 10 def repository @repository end |
Instance Method Details
#import ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/hexabat/client.rb', line 22 def import if EM.reactor_running? start_importing else EM.run &method(:start_importing) end end |
#known_events ⇒ Object
36 37 38 |
# File 'lib/hexabat/client.rb', line 36 def known_events callbacks.keys end |
#on(event_callback) ⇒ Object
30 31 32 33 34 |
# File 'lib/hexabat/client.rb', line 30 def on(event_callback) event = event_callback.keys.first raise_unknown_event_error event unless known? event callbacks.merge! event_callback unless event_callback[event].nil? end |