Sha256: 308ba518a2601d7767098aa02933ea4cfbc2591e2a453da97c498103cbfe2c5b
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
require 'raph/parser/file_parser' require 'raph/parser/flag_parser' require 'raph/parser/assignment_parser' module Raph # TODO: class description class Raph def initialize @parsed = {} @parsers = [] end def parse(args) @all = args.dup @parsers.each do |p| @parsed[p.id.to_sym] = p.parse(@all) end end def all @all.dup end def add_parser(parser) @parsers.push parser end def method_missing(method_sym, *arguments, &block) # TODO: do not accept any arguments or block if has_attribute? method_sym get_attribute_value method_sym else super end end private # Returns true if this class has dynamic argument 'arg' def has_attribute?(arg) @parsed.include? arg end # Returns value of dynamic argument 'arg' def get_attribute_value(arg) @parsed[arg] end end include Parser $raph = Raph.new.tap do |r| r.add_parser(FileParser.new) r.add_parser(FlagParser.new) r.add_parser(AssignmentParser.new) r.parse(ARGV) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
raph-0.0.1 | lib/raph.rb |