Class: Rhymera::List
- Inherits:
-
Object
- Object
- Rhymera::List
- Defined in:
- lib/rhymera/list.rb
Overview
container for lists of Rhyme and Portmanteau
Class Attribute Summary collapse
-
.all ⇒ Object
Returns the value of attribute all.
Instance Attribute Summary collapse
-
#entries ⇒ Object
Returns the value of attribute entries.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #build_correct_type ⇒ Object
- #create_portmanteaus ⇒ Object
- #create_rhymes ⇒ Object
-
#initialize(function:, word:) ⇒ List
constructor
A new instance of List.
Constructor Details
#initialize(function:, word:) ⇒ List
Returns a new instance of List.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rhymera/list.rb', line 14 def initialize(function:, word:) @object = Rhymera::RhymeBrain.query(function: function, word: word) @query = word @type = function @entries = [] build_correct_type # add to all array self.class.all << self end |
Class Attribute Details
.all ⇒ Object
Returns the value of attribute all.
11 12 13 |
# File 'lib/rhymera/list.rb', line 11 def all @all end |
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
5 6 7 |
# File 'lib/rhymera/list.rb', line 5 def entries @entries end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
4 5 6 |
# File 'lib/rhymera/list.rb', line 4 def object @object end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
4 5 6 |
# File 'lib/rhymera/list.rb', line 4 def query @query end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/rhymera/list.rb', line 4 def type @type end |
Instance Method Details
#build_correct_type ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/rhymera/list.rb', line 25 def build_correct_type case @type when 'getRhymes' create_rhymes when 'getPortmanteaus' create_portmanteaus end end |
#create_portmanteaus ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/rhymera/list.rb', line 34 def create_portmanteaus @object.each do |entry| port = Rhymera::Portmanteau.new(source: entry['source'], combined: entry['combined']) entries << port end end |