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

#initialize(mask, by, at) ⇒ Ban

Returns 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



28
29
30
31
32
33
34
35
36
37
# File 'lib/cinch/ban.rb', line 28

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

Instance Attribute Details

#byUser? (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



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

def by
  @by
end

#created_atTime (readonly)

Returns:

  • (Time)


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

def created_at
  @created_at
end

#extendedBoolean (readonly)

Returns 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)



23
24
25
# File 'lib/cinch/ban.rb', line 23

def extended
  @extended
end

#maskMask, String (readonly)

Returns:



10
11
12
# File 'lib/cinch/ban.rb', line 10

def mask
  @mask
end

Instance Method Details

#match(user) ⇒ Boolean Also known as: =~

Returns true if the ban matches ‘user`.

Returns:

  • (Boolean)

    true if the ban matches ‘user`

Raises:



42
43
44
45
# File 'lib/cinch/ban.rb', line 42

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

#to_sString

Returns:



49
50
51
# File 'lib/cinch/ban.rb', line 49

def to_s
  @mask.to_s
end