Class: StubLister
Overview
STUBS
Instance Method Summary collapse
-
#initialize(spec = {:time => Integer}) ⇒ StubLister
constructor
A new instance of StubLister.
- #list ⇒ Object
- #rand_from_spec ⇒ Object
Methods inherited from Lister
Methods inherited from IOAble
#debug!, #debug?, #get_option, #halt!, #job=, #log, #set_option
Constructor Details
#initialize(spec = {:time => Integer}) ⇒ StubLister
Returns a new instance of StubLister.
272 273 274 |
# File 'lib/LRH.rb', line 272 def initialize(spec={:time => Integer}) @spec = spec end |
Instance Method Details
#list ⇒ Object
297 298 299 300 301 302 303 |
# File 'lib/LRH.rb', line 297 def list 10.times do |i| yield rand_from_spec end self end |
#rand_from_spec ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/LRH.rb', line 276 def rand_from_spec hash = {} @spec.each do |key, klass| if [Integer, Numeric].include? klass hash[key] = rand(10000) elsif String == klass hash[key] = (0...rand(100)).map { (('a'..'z').to_a + ('A'..'Z').to_a + ['!', '?', '/', '>', '<'])[rand(57)] }.join elsif Array == klass hash[key] = [] rand(10).times do hash[key].push (0...rand(100)).map { (('a'..'z').to_a + ('A'..'Z').to_a + ['!', '?', '/', '>', '<'])[rand(57)] }.join end else hash[key] = klass end end return hash end |