Class: Cinch::Ban

Inherits:
Object
  • Object
show all
Defined in:
lib/cinch/ban.rb

Overview

This class represents channel bans.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Ban) initialize(mask, by, at)

A new instance of Ban

Parameters:

  • mask (String, Mask)

    The mask

  • by (User, nil)

    The user who created the ban.

  • at (Time)

    The time at which the ban was created



25
26
27
28
29
30
31
32
33
34
# File 'lib/cinch/ban.rb', line 25

def initialize(mask, by, at)
  @by, @created_at = by, at
  if mask =~ /^[\$~]/
    @extended = true
    @mask     = mask
  else
    @extended = false
    @mask = Mask.from(mask)
  end
end

Instance Attribute Details

- (User?) by (readonly)

The user who created the ban. Might be nil on networks that do not strictly follow the RFCs, for example IRCnet in some(?) cases.

Returns:

  • (User, nil)

    The user who created the ban



14
15
16
# File 'lib/cinch/ban.rb', line 14

def by
  @by
end

- (Time) created_at (readonly)

Returns:

  • (Time)


17
18
19
# File 'lib/cinch/ban.rb', line 17

def created_at
  @created_at
end

- (Boolean) extended (readonly)

Whether this is an extended ban (as used by for example Freenode)

Returns:

  • (Boolean)

    whether this is an extended ban (as used by for example Freenode)



20
21
22
# File 'lib/cinch/ban.rb', line 20

def extended
  @extended
end

- (Mask, String) mask (readonly)

Returns:



7
8
9
# File 'lib/cinch/ban.rb', line 7

def mask
  @mask
end

Instance Method Details

- (Boolean) match(user) Also known as: =~

True if the ban matches user

Returns:

  • (Boolean)

    true if the ban matches user

Raises:



39
40
41
42
# File 'lib/cinch/ban.rb', line 39

def match(user)
  raise UnsupportedFeature, "extended bans are not supported yet" if @extended
  @mask =~ user
end

- (String) to_s

Returns:



46
47
48
# File 'lib/cinch/ban.rb', line 46

def to_s
  @mask.to_s
end