Class: Net::IMAP::ConnectionState

Inherits:
Data
  • Object
show all
Defined in:
lib/net/imap/connection_state.rb

Overview

:nodoc:

Constant Summary collapse

NotAuthenticated =
define(:not_authenticated)
Authenticated =
define(:authenticated)
Selected =
define(:selected)
Logout =
define(:logout)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define(symbol, *attrs) ⇒ Object



6
7
8
9
10
11
# File 'lib/net/imap/connection_state.rb', line 6

def self.define(symbol, *attrs)
  symbol => Symbol
  state = super(*attrs)
  state.const_set :NAME, symbol
  state
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


32
# File 'lib/net/imap/connection_state.rb', line 32

def authenticated?;     to_sym == :authenticated     end

#deconstructObject



17
# File 'lib/net/imap/connection_state.rb', line 17

def deconstruct; [symbol, *super] end

#deconstruct_keys(names) ⇒ Object



19
20
21
22
23
24
# File 'lib/net/imap/connection_state.rb', line 19

def deconstruct_keys(names)
  hash = super
  hash[:symbol] = symbol if names.nil? || names.include?(:symbol)
  hash[:name]   = name   if names.nil? || names.include?(:name)
  hash
end

#logout?Boolean

Returns:

  • (Boolean)


34
# File 'lib/net/imap/connection_state.rb', line 34

def logout?;            to_sym == :logout            end

#nameObject



14
# File 'lib/net/imap/connection_state.rb', line 14

def name;   self.class::NAME.name end

#not_authenticated?Boolean

Returns:

  • (Boolean)


31
# File 'lib/net/imap/connection_state.rb', line 31

def not_authenticated?; to_sym == :not_authenticated end

#selected?Boolean

Returns:

  • (Boolean)


33
# File 'lib/net/imap/connection_state.rb', line 33

def selected?;          to_sym == :selected          end

#symbolObject Also known as: to_sym



13
# File 'lib/net/imap/connection_state.rb', line 13

def symbol; self.class::NAME      end

#to_h(&block) ⇒ Object



26
27
28
29
# File 'lib/net/imap/connection_state.rb', line 26

def to_h(&block)
  hash = deconstruct_keys(nil)
  block ? hash.to_h(&block) : hash
end