Module: OptparsePlus::ClassMethods
- Included in:
- OptionParser
- Defined in:
- lib/optparse_plus.rb
Instance Method Summary collapse
Instance Method Details
#new_with_yaml(config_yaml_source = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/optparse_plus.rb', line 18 def new_with_yaml(config_yaml_source=nil) cur_file = caller[0].split(/:/)[0] config_yaml_source ||= read_after_program_end(cur_file) opt = OptPlus.create_opt(config_yaml_source) if block_given? yield opt else opt end end |
#read_after_program_end(cur_file) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/optparse_plus.rb', line 10 def read_after_program_end(cur_file) own_source = File.read(cur_file) last_token = Ripper.lex(own_source)[-1] return nil unless last_token[1] == :on___end__ start = last_token[0][0] own_source.lines[start..-1].join end |