Class: AntiObject

Inherits:
Object show all
Defined in:
lib/anti_object.rb

Constant Summary collapse

VERSION =
'0.6.0'

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ AntiObject

Returns a new instance of AntiObject.



4
5
6
# File 'lib/anti_object.rb', line 4

def initialize(object)
  @object = object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/anti_object.rb', line 16

def method_missing(method_name, *args)
  method_name = method_name.to_s

  if method_name =~ /\?$/
    !(~self).send(method_name, *args)
  else
    raise NoMethodError.new("undefined method `#{method_name}' for #{self}")
  end
end

Instance Method Details

#anti?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/anti_object.rb', line 12

def anti?
  not super
end

#~Object



8
9
10
# File 'lib/anti_object.rb', line 8

def ~
  @object
end