### Home Classes Methods

### In Files

- lib/termtter/hook.rb

### Parent

Object

### Methods

- ::new
- #call
- #match?

### Files

- ChangeLog
- README.rdoc

### Class/Module Index

Quicksearch

- Termtter
- Termtter::API
- Termtter::ActiveRubytter
- Termtter::Client
- Termtter::Client::DirectMessage
- Termtter::Client::Jakigan
- Termtter::Client::SearchEvent
- Termtter::Client::UserSearchEvent
- Termtter::Command
- Termtter::CommandCanceled
- Termtter::CommandLine
- Termtter::CommandNotFound
- Termtter::Config
- Termtter::ConfigSetup
- Termtter::Crypt
- Termtter::English
- Termtter::Event
- Termtter::HTTPpool
- Termtter::Hook
- Termtter::HookCanceled
- Termtter::Hookable
- Termtter::JSONError
- Termtter::MemoryCache
- Termtter::MemoryCache::MemCacheMock
- Termtter::OptParser
- Termtter::Plugin
- Termtter::Plugin::Screen
- Termtter::Plugins
- Termtter::Plugins::Haml
- Termtter::Plugins::ListSwitch
- Termtter::RubytterProxy
- Termtter::RubytterProxy::FrequentAccessError
- Termtter::RubytterProxy::LimitManager
- Termtter::Status
- Termtter::StdOut
- Termtter::Storage
- Termtter::Storage::SQLite3
- Termtter::Storage::Status
- Termtter::Task
- Termtter::TaskManager
- Termtter::TypableIdGenerator
- Termtter::UserStreamReceiver
- Yharian
- Yharian::Alex
- Yharian::Jenifer
- Yharian::Remark
- Yharian::Speaker
- Yharian::Vicki
- Yharian::Yhara
- HatenaKeywordHaiku
- HatenaKeywordHaiku::Word
- OAuth
- OAuth::AccessToken
- Readline
- Readline::LIBREADLINE
- AAMaker
- Array
- BrowserNotFound
- Growl
- IRB
- Object
- Status
- String
- Symbol
- TermColor
- TermtterIrcGateway
- User

No matching classes.

# Termtter::Hook

### Attributes

exec_proc[RW]
name[RW]
points[RW]

### Public Class Methods

new(args) click to toggle source

    # File lib/termtter/hook.rb, line 6
    def initialize(args)
      raise ArgumentError, ":name is not given." unless args.has_key?(:name)
      @name = args[:name].to_sym
      @points = args[:points] || [args[:point]].compact
      @exec_proc = args[:exec_proc] || args[:exec] || lambda {}
    end

### Public Instance Methods

call(*args) click to toggle source

    # File lib/termtter/hook.rb, line 26
    def call(*args)
      begin
        self.exec_proc.call(*args)
      rescue ArgumentError
        args.pop
        retry
      end
    end

match?(point) click to toggle source

    # File lib/termtter/hook.rb, line 13
    def match?(point)
      points.any? {|pt|
        case pt
        when String, Symbol
          pt.to_s == point.to_s
        when Regexp
          (pt =~ point.to_s) ? true : false
        else
          false
        end
      }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.