Class: Cinch::Network

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

Overview

This class allows querying the IRC network for its name and used server software as well as certain non-standard behaviour.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, ircd) ⇒ Network

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

The user should not create instances of this class but use IRC#network instead.

Returns a new instance of Network.

Parameters:

  • name (Symbol)
  • ircd (Symbol)

Since:

  • 2.0.0



35
36
37
38
39
# File 'lib/cinch/network.rb', line 35

def initialize(name, ircd)
  @name         = name
  @ircd         = ircd
  @capabilities = []
end

Instance Attribute Details

#capabilitiesArray<Symbol>

network.

Returns:

  • (Array<Symbol>)

    All client capabilities supported by the

Since:

  • 2.0.0



25
26
27
# File 'lib/cinch/network.rb', line 25

def capabilities
  @capabilities
end

#ircdSymbol

Returns The server software used by the network. :unknown if the software couldn’t be detected.

Returns:

  • (Symbol)

    The server software used by the network. :unknown if the software couldn’t be detected.

Since:

  • 2.0.0



18
19
20
# File 'lib/cinch/network.rb', line 18

def ircd
  @ircd
end

#nameSymbol

Returns The name of the network. :unknown if the network couldn’t be detected.

Returns:

  • (Symbol)

    The name of the network. :unknown if the network couldn’t be detected.

Since:

  • 2.0.0



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

def name
  @name
end

Instance Method Details

#default_messages_per_secondNumeric

Returns The messages per second value that best suits the current network.

Returns:

  • (Numeric)

    The messages per second value that best suits the current network

Since:

  • 2.0.0



86
87
88
89
90
91
92
93
# File 'lib/cinch/network.rb', line 86

def default_messages_per_second
  case @name
  when :freenode
    0.7
  else
    0.5
  end
end

#default_server_queue_sizeInteger

Returns The server queue size value that best suits the current network.

Returns:

  • (Integer)

    The server queue size value that best suits the current network

Since:

  • 2.0.0



97
98
99
100
101
102
103
104
# File 'lib/cinch/network.rb', line 97

def default_server_queue_size
  case @name
  when :quakenet
    40
  else
    10
  end
end

#jtv?Boolean

Returns True if connected to JTV.

Returns:

  • (Boolean)

    True if connected to JTV

Since:

  • 2.0.0



64
65
66
# File 'lib/cinch/network.rb', line 64

def jtv?
  @name == :jtv
end

#ngametv?Boolean

Returns True if connected to NgameTV.

Returns:

  • (Boolean)

    True if connected to NgameTV

Since:

  • 2.0.0



59
60
61
# File 'lib/cinch/network.rb', line 59

def ngametv?
  @name == :ngametv
end

#owner_list_modeString?

Returns The mode used for getting the list of channel owners, if any.

Returns:

  • (String, nil)

    The mode used for getting the list of channel owners, if any

Since:

  • 2.0.0



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

def owner_list_mode
  return "q" if @ircd == :unreal || @ircd == :inspircd
end

#quiet_list_modeString?

Returns The mode used for getting the list of channel quiets, if any.

Returns:

  • (String, nil)

    The mode used for getting the list of channel quiets, if any

Since:

  • 2.0.0



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

def quiet_list_mode
  return "q" if @ircd == :"ircd-seven"
end

#unknown_ircd?Boolean

Returns True if we do not know which software the server is running.

Returns:

  • (Boolean)

    True if we do not know which software the server is running

Since:

  • 2.0.0



76
77
78
# File 'lib/cinch/network.rb', line 76

def unknown_ircd?
  @ircd == :unknown
end

#unknown_network?Boolean

Returns True if we do not know which network we are connected to.

Returns:

  • (Boolean)

    True if we do not know which network we are connected to

Since:

  • 2.0.0



70
71
72
# File 'lib/cinch/network.rb', line 70

def unknown_network?
  @name == :unknown
end

#whois_only_one_argument?Boolean

Returns Does WHOIS only support one argument?.

Returns:

  • (Boolean)

    Does WHOIS only support one argument?

Since:

  • 2.0.0



54
55
56
# File 'lib/cinch/network.rb', line 54

def whois_only_one_argument?
  @name == :jtv
end