Class: Yharian::Remark

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(speaker, words, eos, options = {}) ⇒ Remark

Returns a new instance of Remark.



81
82
83
84
85
86
# File 'lib/plugins/yhara.rb', line 81

def initialize(speaker, words, eos, options = {})
  @speaker = speaker
  @words = words
  @eos = eos # end of text : "?" or "." or "!"
  @pronounciation = options[:pronounciation] || text
end

Instance Attribute Details

#eosObject (readonly)

Returns the value of attribute eos.



79
80
81
# File 'lib/plugins/yhara.rb', line 79

def eos
  @eos
end

#pronounciationObject (readonly)

Returns the value of attribute pronounciation.



79
80
81
# File 'lib/plugins/yhara.rb', line 79

def pronounciation
  @pronounciation
end

#speakerObject (readonly)

Returns the value of attribute speaker.



79
80
81
# File 'lib/plugins/yhara.rb', line 79

def speaker
  @speaker
end

#wordsObject (readonly)

Returns the value of attribute words.



79
80
81
# File 'lib/plugins/yhara.rb', line 79

def words
  @words
end

Instance Method Details

#correct?(s) ⇒ Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/plugins/yhara.rb', line 104

def correct?(s)
  s.gsub(/[^yhar]/,'') == @words.gsub(/[^yhar]/,'')
end

#displayObject



96
97
98
# File 'lib/plugins/yhara.rb', line 96

def display
  puts "#{@speaker.name}: #{text}"
end

#interrogative?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/plugins/yhara.rb', line 92

def interrogative?
  @eos == '?'
end

#say(context = nil) ⇒ Object



100
101
102
# File 'lib/plugins/yhara.rb', line 100

def say(context = nil)
  Kernel.say pronounciation, :voice => @speaker.voice(context)
end

#textObject



88
89
90
# File 'lib/plugins/yhara.rb', line 88

def text
  @words + @eos
end