Top Level Namespace
Defined Under Namespace
Modules: KV
Instance Method Summary collapse
Instance Method Details
#help_io ⇒ Object
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 |
# File 'lib/kv.rb', line 928 def help_io readme = File.read(File.join(__dir__, '../README.md')) help = [] readme.each_line{|line| if /kv: A pager by Ruby Command list/ =~ line help << line elsif /^```/ =~ line && !help.empty? break elsif !help.empty? help << line end } StringIO.new(help.join) end |
#log(obj, prefix = '') ⇒ Object
901 902 903 904 905 906 907 |
# File 'lib/kv.rb', line 901 def log obj, prefix = '' if $debug_log File.open($debug_log, 'a'){|f| f.puts "#{$$} #{prefix}#{obj.inspect}" } end end |
#search_partition(str, search) ⇒ Object
909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 |
# File 'lib/kv.rb', line 909 def search_partition str, search results = [] loop{ r = str.match(search){|m| break if m.post_match == str results << [:unmatch, m.pre_match] unless m.pre_match.empty? results << [:match, m.to_s] str = m.post_match } break unless r } if results.empty? str else results << [:unmatch, str] unless str.empty? results end end |