Module: Cosmos::Structure::MethodMissing

Defined in:
lib/cosmos/packets/structure.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, value = nil) ⇒ Object

Method missing provides reading/writing item values as if they were methods to the class



427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/cosmos/packets/structure.rb', line 427

def method_missing(name, value = nil)
  if @buffer
    if value
      # Strip off the equals sign before looking up the item
      return write(name.to_s[0..-2], value)
    else
      return read(name.to_s)
    end
  else
    raise "No buffer available for method_missing"
  end
end