Class: Rust::Manual
Constant Summary collapse
- @@manuals =
{}
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #about ⇒ Object
-
#initialize(name, description) ⇒ Manual
constructor
A new instance of Manual.
- #inspect ⇒ Object
- #lookup(query) ⇒ Object
- #n_voices ⇒ Object
- #register(voice, matcher, description) ⇒ Object
Constructor Details
#initialize(name, description) ⇒ Manual
Returns a new instance of Manual.
34 35 36 37 38 |
# File 'lib/rust/core/manual.rb', line 34 def initialize(name, description) @name = name @description = description @voices = {} end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
32 33 34 |
# File 'lib/rust/core/manual.rb', line 32 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/rust/core/manual.rb', line 31 def name @name end |
Class Method Details
.about ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/rust/core/manual.rb', line 7 def self.about puts "Manuals available:" @@manuals.each do |category, manual| puts "\t- #{manual.name} (:#{category}) → #{manual.description}" end return nil end |
.for(category) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rust/core/manual.rb', line 16 def self.for(category) category = category.to_sym raise "No manual found for '#{category}'." unless @@manuals[category] return @@manuals[category] end |
Instance Method Details
#about ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rust/core/manual.rb', line 58 def about puts "****** Manual for #@name ******" puts @description puts "Voices in manual #@name:" @voices.keys.each do |key, matcher| puts "\t- #{key}" end return nil end |
#inspect ⇒ Object
73 74 75 |
# File 'lib/rust/core/manual.rb', line 73 def inspect return "Manual for #@name with #{self.n_voices} voices" end |
#lookup(query) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rust/core/manual.rb', line 40 def lookup(query) @voices.each do |key, value| if query.match(key[1]) puts "*** #{key[0]} ***" puts value return end end puts "Voice not found" return nil end |
#n_voices ⇒ Object
54 55 56 |
# File 'lib/rust/core/manual.rb', line 54 def n_voices @voices.size end |
#register(voice, matcher, description) ⇒ Object
69 70 71 |
# File 'lib/rust/core/manual.rb', line 69 def register(voice, matcher, description) @voices[[voice, matcher]] = description end |