Class: Hegel::Generators::CharactersGenerator

Inherits:
Hegel::Generator show all
Defined in:
lib/hegel/generators.rb,
sig/hegel.rbs

Overview

Hegel::Syntax::Methods#characters. A String of exactly one character, sharing TextGenerator's own alphabet options (codec, min_codepoint, max_codepoint) by delegating to a TextGenerator built with min_size and max_size both fixed at 1 -- the same alphabet-building logic, just bounded to a single character instead of a run of them. Opens no span of its own for the same reason TextGenerator does not: the delegated #do_draw is the whole draw, not a composition of several.

Instance Method Summary collapse

Methods inherited from Hegel::Generator

#filter, #map

Constructor Details

#initialize(codec:, min_codepoint:, max_codepoint:) ⇒ CharactersGenerator

Returns a new instance of CharactersGenerator.

Parameters:

  • codec: (String, nil)
  • min_codepoint: (Integer, nil)
  • max_codepoint: (Integer, nil)


413
414
415
416
417
418
419
# File 'lib/hegel/generators.rb', line 413

def initialize(codec:, min_codepoint:, max_codepoint:)
  super()
  @text = TextGenerator.new(
    min_size: 1, max_size: 1, codec: codec,
    min_codepoint: min_codepoint, max_codepoint: max_codepoint
  )
end

Instance Method Details

#do_draw(tc) ⇒ String

Parameters:

  • tc (Object)

Returns:

  • (String)


421
422
423
# File 'lib/hegel/generators.rb', line 421

def do_draw(tc)
  @text.do_draw(tc)
end