Module: CorrectHorseBatteryStaple::Common
- Included in:
- Assembler, CorrectHorseBatteryStaple::Corpus::Base, Generator, Parser::Base, Writer::Base
- Defined in:
- lib/correct_horse_battery_staple.rb
Instance Method Summary collapse
- #array_sample(array, count) ⇒ Object
- #logger ⇒ Object
- #random_in_range(range) ⇒ Object
- #random_number(max = 1.0) ⇒ Object
- #set_sample(array, count) ⇒ Object
Instance Method Details
#array_sample(array, count) ⇒ Object
83 84 85 86 |
# File 'lib/correct_horse_battery_staple.rb', line 83 def array_sample(array, count) l = array.length array.values_at(* count.times.map { random_number(l) }) end |
#logger ⇒ Object
65 66 67 |
# File 'lib/correct_horse_battery_staple.rb', line 65 def logger CorrectHorseBatteryStaple.logger end |
#random_in_range(range) ⇒ Object
79 80 81 |
# File 'lib/correct_horse_battery_staple.rb', line 79 def random_in_range(range) range.first + random_number(range_count(range)) end |
#random_number(max = 1.0) ⇒ Object
70 71 72 |
# File 'lib/correct_horse_battery_staple.rb', line 70 def random_number(max=1.0) Random.rand(max) end |
#set_sample(array, count) ⇒ Object
88 89 90 91 |
# File 'lib/correct_horse_battery_staple.rb', line 88 def set_sample(array, count) l = array.length array.values_at(* count.times.map { random_number(l) }) end |