Class: GamesAndRpgParadise::Lpc::KnowledgeBase
- Inherits:
-
Base
- Object
- Base
- GamesAndRpgParadise::Lpc::KnowledgeBase
show all
- Defined in:
- lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb
Constant Summary
collapse
- LPC_FILE =
'/home/x/rpg/muds/geas/wizard/LPC_CODE_SHEET.md'
Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS
CommonExtensions::CONTROL_C_CODE, CommonExtensions::N
Class Method Summary
collapse
-
.file? ⇒ Boolean
# === GamesAndRpgParadise::Lpc::KnowledgeBase.file? ========================================================================= #.
Instance Method Summary
collapse
ecomment, #efancy, #eparse, #forestgreen, #gold, #grey, #lightblue, #mediumseagreen, #mediumslateblue, #peru, #rev, sdir, sfancy, #sfile, simp, #teal, #yellow
#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments
#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into
Constructor Details
#initialize(optional_search_for = nil, run_already = true) ⇒ KnowledgeBase
27
28
29
30
31
32
33
34
35
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 27
def initialize(
optional_search_for = nil,
run_already = true
)
set_search_for(
optional_search_for
)
run if run_already
end
|
Class Method Details
.file? ⇒ Boolean
#
GamesAndRpgParadise::Lpc::KnowledgeBase.file?
#
50
51
52
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 50
def self.file? return LPC_FILE
end
|
Instance Method Details
#assign_to_tag(i) ⇒ Object
103
104
105
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 103
def assign_to_tag(i)
@tag = i.downcase
end
|
#lpc_file? ⇒ Boolean
126
127
128
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 126
def lpc_file?
LPC_FILE
end
|
#read_lpc_file ⇒ Object
119
120
121
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 119
def read_lpc_file
@file = File.readlines(lpc_file?)
end
|
#report_to_user ⇒ Object
71
72
73
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 71
def report_to_user
e GREEN+'We have '+YEL+@n_keys+GREEN+' keys (Tags).'
end
|
#reset ⇒ Object
40
41
42
43
44
45
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 40
def reset
@all_tags = nil
@hash_tag_data = {}
@tag = ''
@data = ''
end
|
#run ⇒ Object
152
153
154
155
156
157
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 152
def run
read_lpc_file
store_data_into_main_hash
report_to_user
search_for_tag
end
|
#save_data ⇒ Object
110
111
112
113
114
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 110
def save_data
@hash_tag_data[@tag] = @data
@tag = '' @data = ''.dup
end
|
#search_for? ⇒ Boolean
57
58
59
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 57
def search_for?
@search_for
end
|
#search_for_tag(i = search_for?)
) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 133
def search_for_tag(i = search_for?)
if i
e GREEN+'Searching for tag: `'+YELLOW+i+GREEN+'` now (in file '+lpc_file?+').'
matches = @all_tags.select {|t| t =~ /#{i}/}
if matches and ! matches.empty?
matches.each { |key|
e GREEN+key
e YELLOW+@hash_tag_data[key]
cliner
}
else
warn 'No match could be found for `'+GREEN+i+RED+'`.'
end
end
end
|
#set_search_for(i = nil) ⇒ Object
64
65
66
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 64
def set_search_for(i = nil)
@search_for = i
end
|
#store_data_into_main_hash ⇒ Object
#
store_data_into_main_hash
#
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/knowledge_base.rb', line 78
def store_data_into_main_hash
reset
@file.each { |line|
line = line.chomp
next if line.empty?
if line.start_with? ' '
@data << line+N
else
save_data
assign_to_tag(line)
end
}
@all_tags = @hash_tag_data.keys
@n_keys = @all_tags.size.to_s
end
|