Class: Namelab::CLI::Commands::Generate
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Namelab::CLI::Commands::Generate
- Extended by:
- InheritanceHook
- Defined in:
- lib/namelab/cli.rb
Direct Known Subclasses
Instance Method Summary collapse
- #call(samples:, lengths: [], **opts) ⇒ Object
- #output(result) ⇒ Object
-
#outputing ⇒ Object
Yields the block and outputs result.
Methods included from InheritanceHook
Instance Method Details
#call(samples:, lengths: [], **opts) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/namelab/cli.rb', line 40 def call(samples:, lengths: [], **opts) generators = lengths.each_with_object(opts).map(&WordGenerator) samples.to_i.times do outputing { generators.map(&:call).join(" ") } end end |
#output(result) ⇒ Object
55 56 57 |
# File 'lib/namelab/cli.rb', line 55 def output(result) puts result end |
#outputing ⇒ Object
Yields the block and outputs result.
49 50 51 52 53 |
# File 'lib/namelab/cli.rb', line 49 def outputing # :yields: result = yield fail "Empty result" unless result && result.size > 0 output(result) end |