Class: MylibCommand
Instance Method Summary collapse
- #do_list ⇒ Object
- #do_pieces ⇒ Object (also: #do_piece)
-
#initialize ⇒ MylibCommand
constructor
A new instance of MylibCommand.
- #run ⇒ Object
Constructor Details
#initialize ⇒ MylibCommand
Returns a new instance of MylibCommand.
990 991 992 |
# File 'lib/el4r/el4r-sub.rb', line 990 def initialize @lines = File.readlines($0) end |
Instance Method Details
#do_list ⇒ Object
1003 1004 1005 1006 1007 |
# File 'lib/el4r/el4r-sub.rb', line 1003 def do_list @lines.select{|line| line =~ /^ *(class|module|def|attr|attr_reader|attr_writer|attr_accessor) |^#### / }.display end |
#do_pieces ⇒ Object Also known as: do_piece
1009 1010 1011 1012 1013 1014 1015 1016 1017 |
# File 'lib/el4r/el4r-sub.rb', line 1009 def do_pieces @lines.inject([]){|result, line| if line =~ /^#### (.+?)/ result + ["#{$1}\n"] else result end }.display end |
#run ⇒ Object
994 995 996 997 998 999 1000 1001 |
# File 'lib/el4r/el4r-sub.rb', line 994 def run meth = "do_#{ARGV[0]}" if respond_to?(meth) __send__ meth else do_list end end |