Class: Drnbench::RequestResponse::RequestPattern::PatternsGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/drnbench/request-response/request-pattern.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, abstract) ⇒ PatternsGroup

Returns a new instance of PatternsGroup.



101
102
103
104
# File 'lib/drnbench/request-response/request-pattern.rb', line 101

def initialize(source, abstract)
  @source = source
  @abstract = abstract
end

Instance Attribute Details

#abstractObject (readonly)

Returns the value of attribute abstract.



99
100
101
# File 'lib/drnbench/request-response/request-pattern.rb', line 99

def abstract
  @abstract
end

Class Method Details

.valid_source?(source) ⇒ Boolean

Returns:

  • (Boolean)


88
89
90
91
92
93
94
95
96
# File 'lib/drnbench/request-response/request-pattern.rb', line 88

def valid_source?(source)
  if source.is_a?(Array)
    return Pattern.valid_source?(source.first)
  end
  if source.is_a?(Hash)
    return source.has_key?("patterns")
  end
  false
end

Instance Method Details

#frequencyObject



106
107
108
109
110
111
# File 'lib/drnbench/request-response/request-pattern.rb', line 106

def frequency
  if @source.is_a?(Hash) and @source.has_key?("frequency")
    return @source["frequency"].to_f
  end
  @abstract.default_group_frequency
end

#hostObject



113
114
115
116
# File 'lib/drnbench/request-response/request-pattern.rb', line 113

def host
  return nil unless @source.is_a?(Hash)
  @source["host"]
end

#methodObject



123
124
125
126
# File 'lib/drnbench/request-response/request-pattern.rb', line 123

def method
  return nil unless @source.is_a?(Hash)
  @source["method"]
end

#patternsObject



133
134
135
# File 'lib/drnbench/request-response/request-pattern.rb', line 133

def patterns
  @patterns ||= prepare_patterns
end

#portObject



118
119
120
121
# File 'lib/drnbench/request-response/request-pattern.rb', line 118

def port
  return nil unless @source.is_a?(Hash)
  @source["port"]
end

#timeoutObject



128
129
130
131
# File 'lib/drnbench/request-response/request-pattern.rb', line 128

def timeout
  return nil unless @source.is_a?(Hash)
  @source["timeout"]
end