Class: Hiq::LineComposer

Inherits:
Object
  • Object
show all
Includes:
Syllabizable
Defined in:
lib/hiq/domain/line_composer.rb

Overview

service responsible for composing a single line of Haiku

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Syllabizable

#diphtongs, #silent_e_count, #syllables, #triphtongs

Constructor Details

#initialize(line, target_syllable_length:, library:) ⇒ LineComposer

Returns a new instance of LineComposer.



14
15
16
17
18
# File 'lib/hiq/domain/line_composer.rb', line 14

def initialize(line, target_syllable_length:, library:)
  @line = line
  @target_syllable_length = target_syllable_length
  @library = library
end

Instance Attribute Details

#libraryObject (readonly)

Returns the value of attribute library.



8
9
10
# File 'lib/hiq/domain/line_composer.rb', line 8

def library
  @library
end

#lineObject (readonly)

Returns the value of attribute line.



8
9
10
# File 'lib/hiq/domain/line_composer.rb', line 8

def line
  @line
end

#target_syllable_lengthObject (readonly)

Returns the value of attribute target_syllable_length.



8
9
10
# File 'lib/hiq/domain/line_composer.rb', line 8

def target_syllable_length
  @target_syllable_length
end

Class Method Details

.call(line, target_syllable_length:, library:) ⇒ Object



10
11
12
# File 'lib/hiq/domain/line_composer.rb', line 10

def self.call(line, target_syllable_length:, library:)
  new(line, target_syllable_length: target_syllable_length, library: library).call
end

Instance Method Details

#callObject



20
21
22
23
24
# File 'lib/hiq/domain/line_composer.rb', line 20

def call
  return line if syllable_gap_size.zero?

  filled_line
end