Class: JayZ::Ghost

Inherits:
Object
  • Object
show all
Defined in:
lib/jay_z/ghost.rb

Instance Method Summary collapse

Constructor Details

#initialize(serial_number) ⇒ Ghost

Returns a new instance of Ghost.



3
4
5
# File 'lib/jay_z/ghost.rb', line 3

def initialize(serial_number)
  @serial_number = serial_number
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jay_z/ghost.rb', line 15

def method_missing(method, *args, &block)
  if block_given?
    keys << method
    m = Module.new do
      define_method(method, &block)
    end
    extend m
  else
    super
  end
end

Instance Method Details

#keysObject



11
12
13
# File 'lib/jay_z/ghost.rb', line 11

def keys
  @keys ||= []
end

#snObject



7
8
9
# File 'lib/jay_z/ghost.rb', line 7

def sn
  @serial_number.next
end