Class: Hyrum::Generators::FakeGenerator
- Inherits:
-
Object
- Object
- Hyrum::Generators::FakeGenerator
- Defined in:
- lib/hyrum/generators/fake_generator.rb
Constant Summary collapse
- DATA_FILE =
File.('../data/fake_messages.json', __dir__)
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(options) ⇒ FakeGenerator
constructor
A new instance of FakeGenerator.
Constructor Details
#initialize(options) ⇒ FakeGenerator
Returns a new instance of FakeGenerator.
10 11 12 |
# File 'lib/hyrum/generators/fake_generator.rb', line 10 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/hyrum/generators/fake_generator.rb', line 8 def @options end |
Instance Method Details
#generate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hyrum/generators/fake_generator.rb', line 14 def generate = key = [:key]&.to_s&.downcase number = ([:number] || 1).to_i return unless key key_with_prefix = key.start_with?('e') ? key : "e#{key}" = [key_with_prefix] || [] = .sample([number, .length].min) # Prepend the original message if provided = [[:message]] + if [:message] # Return as a hash to match expected format { [:key] => } end |