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.
- #method_missing(key, *args) ⇒ Object
Constructor Details
#initialize(*options, &block) ⇒ Options
Returns a new instance of Options.
147 148 149 150 151 |
# File 'lib/orange-core/magick.rb', line 147 def initialize(*, &block) = . ||= {} 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
157 158 159 160 161 162 163 164 165 166 |
# File 'lib/orange-core/magick.rb', line 157 def method_missing(key, *args) return ([key.to_s.gsub(/\?$/, '').to_sym].eql?(true)) if key.to_s.match(/\?$/) if args.empty? [key.to_sym] elsif(key.to_s.match(/\=$/)) [key.to_s.gsub(/\=$/, '').to_sym] = (args.size == 1 ? args.first : args) else [key.to_sym] = (args.size == 1 ? args.first : args) end end |
Instance Method Details
#hash ⇒ Object
153 154 155 |
# File 'lib/orange-core/magick.rb', line 153 def hash end |