Class: Rhymera::Portmanteau

Inherits:
Object
  • Object
show all
Defined in:
lib/rhymera/portmanteau.rb

Overview

converts RhymeBrain json data to object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, combined:) ⇒ Portmanteau

Returns a new instance of Portmanteau.



6
7
8
9
10
11
12
13
# File 'lib/rhymera/portmanteau.rb', line 6

def initialize(source:, combined:)
  source_words = source.split(',')
  combined_words = combined.split(',')
  @prefix = source_words[0]
  @suffix = source_words[1]
  @word = combined_words[0]
  @alternative = combined_words[1] if combined_words[1]
end

Instance Attribute Details

#alternativeObject (readonly)

Returns the value of attribute alternative.



4
5
6
# File 'lib/rhymera/portmanteau.rb', line 4

def alternative
  @alternative
end

#prefixObject (readonly)

Returns the value of attribute prefix.



4
5
6
# File 'lib/rhymera/portmanteau.rb', line 4

def prefix
  @prefix
end

#suffixObject (readonly)

Returns the value of attribute suffix.



4
5
6
# File 'lib/rhymera/portmanteau.rb', line 4

def suffix
  @suffix
end

#wordObject (readonly)

Returns the value of attribute word.



4
5
6
# File 'lib/rhymera/portmanteau.rb', line 4

def word
  @word
end