Class: Yharian::Remark

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Remark.



79
80
81
82
83
84
# File 'lib/plugin/yhara.rb', line 79

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.



77
78
79
# File 'lib/plugin/yhara.rb', line 77

def eos
  @eos
end

#pronounciationObject (readonly)

Returns the value of attribute pronounciation.



77
78
79
# File 'lib/plugin/yhara.rb', line 77

def pronounciation
  @pronounciation
end

#speakerObject (readonly)

Returns the value of attribute speaker.



77
78
79
# File 'lib/plugin/yhara.rb', line 77

def speaker
  @speaker
end

#wordsObject (readonly)

Returns the value of attribute words.



77
78
79
# File 'lib/plugin/yhara.rb', line 77

def words
  @words
end

Instance Method Details

#correct?(s) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/plugin/yhara.rb', line 102

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

#displayObject



94
95
96
# File 'lib/plugin/yhara.rb', line 94

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

#interrogative?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/plugin/yhara.rb', line 90

def interrogative?
  @eos == '?'
end

#say(context = nil) ⇒ Object



98
99
100
# File 'lib/plugin/yhara.rb', line 98

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

#textObject



86
87
88
# File 'lib/plugin/yhara.rb', line 86

def text
  @words + @eos
end