Class: Otaku::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/otaku/handler.rb,
lib/otaku/handler/context.rb,
lib/otaku/handler/processor.rb,
lib/otaku/handler/magic_proc.rb

Defined Under Namespace

Classes: Context, MagicProc, Processor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, handler) ⇒ Handler

Returns a new instance of Handler.



10
11
12
13
# File 'lib/otaku/handler.rb', line 10

def initialize(context, handler)
  @context = Context.new(context)
  @processor = Processor.new(handler)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#processorObject (readonly)

Returns the value of attribute processor.



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

def processor
  @processor
end

Instance Method Details

#marshal_dumpObject



23
24
25
# File 'lib/otaku/handler.rb', line 23

def marshal_dump
  [@context, @processor]
end

#marshal_load(data) ⇒ Object



27
28
29
# File 'lib/otaku/handler.rb', line 27

def marshal_load(data)
  @context, @processor = data
end

#process(data) ⇒ Object



15
16
17
# File 'lib/otaku/handler.rb', line 15

def process(data)
  @context.eval!.instance_exec(data, &@processor.eval!)
end

#rootObject



19
20
21
# File 'lib/otaku/handler.rb', line 19

def root
  File.dirname(@processor.file)
end