Class: Hiq::Haiku

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

Overview

Haiku generating object

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Syllabizable

#diphtongs, #silent_e_count, #syllables, #triphtongs

Constructor Details

#initialize(words) ⇒ Haiku

Returns a new instance of Haiku.



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

def initialize(words)
  @words = words.sort_by(&:size)
end

Instance Attribute Details

#wordsObject (readonly)

Returns the value of attribute words.



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

def words
  @words
end

Instance Method Details

#to_sObject



14
15
16
# File 'lib/hiq/haiku.rb', line 14

def to_s
  haiku_lines.map { |l| l.join(' ') }.join("\n")
end