Class: Beats::Command::Sentence

Inherits:
Base
  • Object
show all
Defined in:
lib/beats/commands/sentence.rb

Instance Attribute Summary

Attributes inherited from Base

#args

Instance Method Summary collapse

Methods inherited from Base

has_command?, #initialize

Constructor Details

This class inherits a constructor from Beats::Command::Base

Instance Method Details

#sentenceObject



5
6
7
8
9
10
# File 'lib/beats/commands/sentence.rb', line 5

def sentence
  display(client.sentence['fields'].map { |field|
    option = field['options'][rand(field['options'].size)]
    [option['prefix'] || field['prefix'], "{#{option['name']}}", option['suffix'] || field['suffix']]
  }.flatten.compact.join(' '))
end