Class: VIN::Request

Inherits:
Object
  • Object
show all
Includes:
Mixins::Redis
Defined in:
lib/vin/request.rb

Constant Summary collapse

MAX_TRIES =
5

Constants included from Mixins::Redis

Mixins::Redis::DEFAULT_REDIS_URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Redis

#redis

Constructor Details

#initialize(config, data_type, count = 1, custom_timestamp: nil) ⇒ Request

Returns a new instance of Request.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vin/request.rb', line 9

def initialize(config, data_type, count = 1, custom_timestamp: nil)
  raise(ArgumentError, "data_type must be a number") unless data_type.is_a?(Numeric)
  unless config.data_type_allowed_range.include?(data_type)
    raise(ArgumentError, "data_type is outside the allowed range of #{config.data_type_allowed_range}")
  end
  raise(ArgumentError, "count must be a number") unless count.is_a?(Numeric)
  raise(ArgumentError, "count must be greater than zero") unless count.positive?

  @tries = 0
  @data_type = data_type
  @count = count
  @config = config
  @custom_timestamp = custom_timestamp
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/vin/request.rb', line 7

def config
  @config
end

#countObject (readonly)

Returns the value of attribute count.



7
8
9
# File 'lib/vin/request.rb', line 7

def count
  @count
end

#custom_timestampObject (readonly)

Returns the value of attribute custom_timestamp.



7
8
9
# File 'lib/vin/request.rb', line 7

def custom_timestamp
  @custom_timestamp
end

#data_typeObject (readonly)

Returns the value of attribute data_type.



7
8
9
# File 'lib/vin/request.rb', line 7

def data_type
  @data_type
end

Instance Method Details

#responseObject



24
25
26
# File 'lib/vin/request.rb', line 24

def response
  Response.new(try_redis_response)
end