Class: InternetHakai::RegexpSetVarAction

Inherits:
RequestAction show all
Defined in:
lib/internethakai/action.rb

Overview

正規表現で取得した変数をセットするアクション

Constant Summary

Constants inherited from RequestAction

InternetHakai::RequestAction::ERROR_MAX, InternetHakai::RequestAction::REDIRECT_MAX

Instance Attribute Summary

Attributes inherited from BaseAction

#performance_id

Instance Method Summary collapse

Methods inherited from RequestAction

#check_scan, #check_size, #free, #get_client, #get_default, #http_request, #init, #initialize, #log, #mkclient, #on_complete, #on_error, #on_free, #on_redirect, #run, #set_client, #set_wait, #to_s

Methods inherited from BaseAction

#dispatch_next, #free, #get_default, #has_on_complete?, #initialize, #quit, #run, #set_on_complete

Constructor Details

This class inherits a constructor from InternetHakai::RequestAction

Instance Method Details

#on_response(response) ⇒ Object



310
311
312
313
314
315
316
317
318
319
320
# File 'lib/internethakai/action.rb', line 310

def on_response response
    return if response.nil? || response.status != 200
    if @opt['key'] && @opt['expr']
        r = @opt['compiled_expr']
        r =~ response.body
        if Regexp.last_match
            @client_handler.set_var(@opt['key'],Regexp.last_match(1))
            @debug_msgs << "REGEXP_SET_VAR:::#{@opt['key']}: #{Regexp.last_match(1)}\n"
        end
    end
end