Class: Linguistics::Latin::Util::LatinIRB
- Inherits:
-
Object
- Object
- Linguistics::Latin::Util::LatinIRB
- Defined in:
- lib/latinirb/version.rb,
lib/latinirb/LatinIRB.rb
Constant Summary collapse
- VERSION =
"1.0.3"
Class Method Summary collapse
- .begin ⇒ Object
- .configure_irb_singleton ⇒ Object
- .configure_latinverb_prompt ⇒ Object
- .get_irb_singleton ⇒ Object
- .print_prelude ⇒ Object
- .set_required_main_irb_context ⇒ Object
Class Method Details
.begin ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/latinirb/LatinIRB.rb', line 10 def self.begin configure_irb_singleton @irb = get_irb_singleton set_required_main_irb_context configure_latinverb_prompt print_prelude trap("SIGINT") do irb.signal_handle end begin catch(:IRB_EXIT) do # Start the REPL @irb.eval_input end end puts "Vale! Come back to LatinIRB soon." end |
.configure_irb_singleton ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/latinirb/LatinIRB.rb', line 44 def self.configure_irb_singleton IRB.setup(nil) @CONF = IRB.conf # This will be the script IRB sources on execution. You can # pre-define variables (AFIRST, etc.) and convenience methods here. @CONF[:SCRIPT]=File.join(File.dirname(__FILE__), %w|latinirb_paradigmatic_verbs.rb|) # No, do not tell me what you read in @CONF[:ECHO]=false # Nor tell me how it evaluated @CONF[:VERBOSE]=false end |
.configure_latinverb_prompt ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/latinirb/LatinIRB.rb', line 31 def self.configure_latinverb_prompt # Create a LatinIRB prompt @CONF[:PROMPT][:LATINIRB] = { :PROMPT_I => "LatinIRB > ", :PROMPT_S => "LatinIRB%l> ", :PROMPT_C => "LatinIRB > ", :PROMPT_N => "LatinIRB ?> ", :RETURN => " => %s \n", :AUTO_INDENT => true } @CONF[:PROMPT_MODE]=:LATINIRB end |
.get_irb_singleton ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/latinirb/LatinIRB.rb', line 60 def self.get_irb_singleton # Create an irb object that is programmed to source a configuration # file that ends with a call to 'irb' itself after defining several # instance variables @CONF[:LOAD_MODULES]=["latinverb"] IRB::Irb.new(nil, @CONF[:SCRIPT]) end |
.print_prelude ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/latinirb/LatinIRB.rb', line 69 def self.print_prelude puts <<-EOT The following verbs have been made available to this session: * AFIRST / AFIRST_DEP * ASECOND / ASECOND_DEP * ATHIRD / ATHIRD_DEP * ATHIRDIO / ATHIRDIO_DEP * AFOURTH / AFOURTH_DEP As well as some primary irregulars: * TO_BE * TO_CARRY * TO_COME Tab-completion of the conjugation \"vectors\" is supported. Helpful methods: * `LatinVerb.new("amō amāre amāvī amatum")`: create a new LatinVerb instance * `v(latex_representation_of_macronized_string)` * `chart(verb)`: prints a verb's chart * `b(verb)`: prints the `active_voice_indicative_mood_present_tense_first_person_singular_number` of `verb` Verb strings can be entered using the LaTeX-style ASCII representations of macron-bearing letters e.g.: \\={e}, \\={a}, and NB: \\={\\i} EOT puts "" end |
.set_required_main_irb_context ⇒ Object
100 101 102 103 |
# File 'lib/latinirb/LatinIRB.rb', line 100 def self.set_required_main_irb_context # Unless this is set, eval_input will fail. @CONF[:MAIN_CONTEXT] = @irb.context end |