Class: Cinch::Ban

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mask, by, at) ⇒ Ban

Returns a new instance of Ban.

Parameters:

  • mask (String)

    The mask

  • by (User)

    The user who created the ban

  • at (Time)

    The time at which the ban was created



19
20
21
22
23
24
25
26
27
28
# File 'lib/cinch/ban.rb', line 19

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

Instance Attribute Details

#byUser (readonly)

Returns:



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

def by
  @by
end

#created_atTime (readonly)

Returns:

  • (Time)


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

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)



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

def extended
  @extended
end

#maskMask, String (readonly)

Returns:



5
6
7
# File 'lib/cinch/ban.rb', line 5

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:



33
34
35
36
# File 'lib/cinch/ban.rb', line 33

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

#to_sString

Returns:



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

def to_s
  @mask.to_s
end