Class: Tchae::KeywordArgs
Instance Method Summary collapse
- #expect(**keywprocs) ⇒ Object
-
#initialize(wrapper) ⇒ KeywordArgs
constructor
A new instance of KeywordArgs.
- #valid_or_raise_exception(keywps) ⇒ Object
- #valid_or_return_error(keywps) ⇒ Object
Constructor Details
#initialize(wrapper) ⇒ KeywordArgs
Returns a new instance of KeywordArgs.
239 240 241 242 |
# File 'lib/tchae/core.rb', line 239 def initialize(wrapper) super() @wrapper = wrapper end |
Instance Method Details
#expect(**keywprocs) ⇒ Object
244 245 246 247 |
# File 'lib/tchae/core.rb', line 244 def expect(**keywprocs) keywprocs.each { |argsymb, proc| self[argsymb] = Tchae(proc) } @wrapper end |
#valid_or_raise_exception(keywps) ⇒ Object
249 250 251 252 253 254 255 256 |
# File 'lib/tchae/core.rb', line 249 def valid_or_raise_exception(keywps) each do |key, valtor| next unless valtor next unless ((parm = keywps[key]) if keywps.key?(key)) valtor.valid_or_raise_exception(parm, ::Tchae::ArgumentTypeException) end end |
#valid_or_return_error(keywps) ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/tchae/core.rb', line 258 def valid_or_return_error(keywps) # returns nil if everything valid or an Error object otherwise valid = true failed = each do |key, valtor| next unless valtor next unless ((parm = keywps[key]) if keywps.key?(key)) unless valtor.execute(parm) valid = false break valtor.return_error(parm, ::Tchae::ArgumentTypeError) end end valid ? nil : failed end |