Class: Yharian::Speaker
- Inherits:
-
Object
- Object
- Yharian::Speaker
- Defined in:
- lib/plugins/yhara.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ Speaker
constructor
A new instance of Speaker.
- #talk(context) ⇒ Object
- #voice(context = nil) ⇒ Object
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
#name ⇒ Object (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 |