Class: Orange::Options
Overview
Simple class for evaluating options and allowing us to access them.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(*options, &block) ⇒ Options
constructor
A new instance of Options.
-
#load(*args) ⇒ Object
Load needs fixing up.
- #method_missing(key, *args) ⇒ Object
Constructor Details
#initialize(*options, &block) ⇒ Options
Returns a new instance of Options.
151 152 153 154 155 156 |
# File 'lib/orange-core/magick.rb', line 151 def initialize(*, &block) @core = .first if(.size > 0 && .first.kind_of?(Orange::Core)) @options = . @options ||= {} instance_eval(&block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *args) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/orange-core/magick.rb', line 167 def method_missing(key, *args) return (@options[key.to_s.gsub(/\?$/, '').to_sym].eql?(true)) if key.to_s.match(/\?$/) if args.empty? @options[key.to_sym] elsif(@core && @core.respond_to?(key.to_sym)) @core.__send__(key, *args) elsif(key.to_s.match(/\=$/)) @options[key.to_s.gsub(/\=$/, '').to_sym] = (args.size == 1 ? args.first : args) else @options[key.to_sym] = (args.size == 1 ? args.first : args) end end |