Class: Ykutils::StructuredText
- Inherits:
-
Object
- Object
- Ykutils::StructuredText
- Includes:
- DataStructOp, DebugUtils, SpecFileOp
- Defined in:
- lib/ykutils/stext.rb
Direct Known Subclasses
StructuredTextForAccount, StructuredTextForFtpOp, StructuredTextForSimple, StructuredTextForX
Constant Summary
Constants included from NKFUTIL
Instance Attribute Summary collapse
-
#item_ary ⇒ Object
readonly
Returns the value of attribute item_ary.
-
#main_ary ⇒ Object
readonly
Returns the value of attribute main_ary.
-
#main_hash ⇒ Object
readonly
Returns the value of attribute main_hash.
Instance Method Summary collapse
- #analyze(line_ary, subfname = nil) ⇒ Object
- #dump_to_file(fname) ⇒ Object
-
#initialize(debug: false) ⇒ StructuredText
constructor
A new instance of StructuredText.
- #load(fname) ⇒ Object
- #load_analyze(fname, subfname = nil) ⇒ Object
Methods included from DebugUtils
#clear_d, #d, #d_caller, #d_exit, #d_p, #d_pp, #d_puts, #d_puts_no_empty, #debug_utils_init, #error_exit, #puts_current_method, #puts_d, #puts_no_empty, #w1_puts, #w2_puts
Methods included from DataStructOp
#exchange, #make_array, #make_hash, #select_array
Methods included from SpecFileOp
#check_data_complement, #check_data_complement_print_message, #dump_yaml_fileobj, #expand_data, #load_csv_file, #load_csv_file_ex, #load_plain_text_file, #load_yaml_file, #make_data_complement, #open_for_write, #parse_yaml_file, #save_yaml_file, #valid?
Methods included from NKFUTIL
assoc_equal, auto_config_from_inner, auto_config_to_inner, config, convert, get, guess_encoding, #nkf_utf8_file, #puts_sj, #puts_u, set
Constructor Details
#initialize(debug: false) ⇒ StructuredText
Returns a new instance of StructuredText.
17 18 19 20 21 22 23 24 |
# File 'lib/ykutils/stext.rb', line 17 def initialize(debug: false) @text = nil @fname = nil @text_ary = [] debug_utils_init debug(debug) end |
Instance Attribute Details
#item_ary ⇒ Object (readonly)
Returns the value of attribute item_ary.
11 12 13 |
# File 'lib/ykutils/stext.rb', line 11 def item_ary @item_ary end |
#main_ary ⇒ Object (readonly)
Returns the value of attribute main_ary.
11 12 13 |
# File 'lib/ykutils/stext.rb', line 11 def main_ary @main_ary end |
#main_hash ⇒ Object (readonly)
Returns the value of attribute main_hash.
11 12 13 |
# File 'lib/ykutils/stext.rb', line 11 def main_hash @main_hash end |
Instance Method Details
#analyze(line_ary, subfname = nil) ⇒ Object
40 |
# File 'lib/ykutils/stext.rb', line 40 def analyze(line_ary, subfname = nil); end |
#dump_to_file(fname) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ykutils/stext.rb', line 42 def dump_to_file(fname) FileX.open(fname, "w") do |file| @text_ary.each do |l| file.write("#{l}\n") end end rescue StandardError => e pp e pp e.backtrace @valid = false end |
#load(fname) ⇒ Object
36 37 38 |
# File 'lib/ykutils/stext.rb', line 36 def load(fname) load_plain_text_file(fname).collect(&:chomp) end |
#load_analyze(fname, subfname = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/ykutils/stext.rb', line 26 def load_analyze(fname, subfname = nil) # puts_current_method # puts "-0 fname=#{fname}" @fname = fname @text_ary = load(fname) # @text_ary.each do |x| puts x end analyze(@text_ary, subfname) end |