Class: Yharian::Speaker

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/yhara.rb

Direct Known Subclasses

Alex, Jenifer, Vicki, Yhara

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Speaker

Returns a new instance of Speaker.



20
21
22
# File 'lib/plugins/yhara.rb', line 20

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/plugins/yhara.rb', line 19

def name
  @name
end

Instance Method Details

#talk(context) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/plugins/yhara.rb', line 24

def talk(context)
  n = 7
  words = (0..rand(n)).map { %w[y hara].choice }.
    inject {|r, e| r + (rand < 0.97 ? ' ' : ', ') + e }
  eos = %w(? ? . . . . . . . . !).choice
  [Remark.new(self,words, eos)]
end

#voice(context = nil) ⇒ Object



32
33
34
# File 'lib/plugins/yhara.rb', line 32

def voice(context = nil)
  @name
end