Class: Hirsute::ReadFromFileGenerator
- Defined in:
- lib/hirsute_generator.rb
Instance Method Summary collapse
- #_generate(onObj) ⇒ Object
-
#initialize(file_name, algorithm, block) ⇒ ReadFromFileGenerator
constructor
A new instance of ReadFromFileGenerator.
Methods inherited from Generator
Methods included from Support
#class_for_name, #generator_from_value, get_range_array, #integer_from_histogram, #is_template, #make_template, #random_from_range, #random_item_with_histogram
Methods included from HistoParse
Constructor Details
#initialize(file_name, algorithm, block) ⇒ ReadFromFileGenerator
Returns a new instance of ReadFromFileGenerator.
77 78 79 80 81 82 |
# File 'lib/hirsute_generator.rb', line 77 def initialize(file_name,algorithm,block) @file_name = file_name @file = File.open @file_name @algorithm = algorithm super(block) end |
Instance Method Details
#_generate(onObj) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/hirsute_generator.rb', line 84 def _generate(onObj) if @algorithm == :markov advance_count = rand(100) read_line_at(advance_count) elsif @algorithm == :linear read_line_at(1) else raise "Unknown read_from_file algorithm: " + @algorithm end end |