Class: TapRep::Client

Inherits:
Struct
  • Object
show all
Defined in:
lib/client.rb

Overview

rubocop:disable Metrics/BlockLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Client

Returns a new instance of Client.



15
16
17
# File 'lib/client.rb', line 15

def initialize(**kwargs)
  super(*members.map { |k| kwargs[k] })
end

Instance Attribute Details

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



14
15
16
# File 'lib/client.rb', line 14

def state
  @state
end

#streamObject

Returns the value of attribute stream

Returns:

  • (Object)

    the current value of stream



14
15
16
# File 'lib/client.rb', line 14

def stream
  @stream
end

#tokenObject

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



14
15
16
# File 'lib/client.rb', line 14

def token
  @token
end

#verboseObject

Returns the value of attribute verbose

Returns:

  • (Object)

    the current value of verbose



14
15
16
# File 'lib/client.rb', line 14

def verbose
  @verbose
end

Instance Method Details

#output(hash) ⇒ Object



28
29
30
# File 'lib/client.rb', line 28

def output(hash)
  stream.puts JSON.generate(hash)
end

#process(model) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/client.rb', line 19

def process(model)
  records = get(model)
  return unless records.any?

  output_records model, records
  output_state model, records.last['end_time']
  process model
end