Class: EnhancedPrompt::Prompt::Token

Inherits:
Object
  • Object
show all
Includes:
EmojiWritable
Defined in:
lib/enhanced_prompt/token/token.rb,
lib/enhanced_prompt/token/dir.rb,
lib/enhanced_prompt/token/dir.rb,
lib/enhanced_prompt/token/time.rb

Overview

Responsible for delegating instructions to proper instance. And convert into proper string after receiving Integer, AddrInfo or something else

Defined Under Namespace

Classes: Dir, Git, Network, SystemResource, Time, User

Instance Method Summary collapse

Methods included from EmojiWritable

#vertical_bar_scale

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



128
129
130
131
# File 'lib/enhanced_prompt/token/token.rb', line 128

def method_missing(name,*args)
  puts "No such token. "
  raise super
end

Instance Method Details

#dir_abbreviated1(limit = 40) ⇒ Object

Delegating to Dir resources



89
90
91
# File 'lib/enhanced_prompt/token/token.rb', line 89

def dir_abbreviated1(limit=40)
  _dir.dir_abbreviated1(limit).to_s || ""
end

#dir_fullObject



93
94
95
# File 'lib/enhanced_prompt/token/token.rb', line 93

def dir_full
  _dir.dir_full.to_s
end

#gidObject



84
85
86
# File 'lib/enhanced_prompt/token/token.rb', line 84

def gid
  _user.gid.to_s || "No #{__method__}"
end

#gitObject



97
98
99
# File 'lib/enhanced_prompt/token/token.rb', line 97

def git
  _git.git
end

#global_ipv4Object



18
19
20
# File 'lib/enhanced_prompt/token/token.rb', line 18

def global_ipv4
  _network.global_ipv4 ? _network.global_ipv4.inspect_sockaddr : ''
end

#global_ipv6Object



22
23
24
# File 'lib/enhanced_prompt/token/token.rb', line 22

def global_ipv6
  _network.global_ipv6 ? _network.global_ipv6.inspect_sockaddr : ''
end

#groupnameObject



39
40
41
# File 'lib/enhanced_prompt/token/token.rb', line 39

def groupname
  _user.groupname || ''
end

#hostnameObject



30
31
32
# File 'lib/enhanced_prompt/token/token.rb', line 30

def hostname
  _network.hostname || ''
end

#hostname_fullObject



26
27
28
# File 'lib/enhanced_prompt/token/token.rb', line 26

def hostname_full
  _network.hostname_full || ''
end

#ipv4Object

Delegating to Network resource



10
11
12
# File 'lib/enhanced_prompt/token/token.rb', line 10

def ipv4
  _network.ipv4 ? _network.ipv4.inspect_sockaddr : ''
end

#ipv6Object



14
15
16
# File 'lib/enhanced_prompt/token/token.rb', line 14

def ipv6
  _network.ipv6 ? _network.ipv6.inspect_sockaddr : ''
end

#login_countObject



68
69
70
# File 'lib/enhanced_prompt/token/token.rb', line 68

def 
  _user..to_s
end

#my_login_countObject



72
73
74
# File 'lib/enhanced_prompt/token/token.rb', line 72

def 
  _user..to_s
end

#other_login_countObject



76
77
78
# File 'lib/enhanced_prompt/token/token.rb', line 76

def 
  _user..to_s
end

#other_user_namesObject



47
48
49
# File 'lib/enhanced_prompt/token/token.rb', line 47

def other_user_names
  _user.other_usernames.join(',')
end

#other_user_names_if_existsObject



51
52
53
# File 'lib/enhanced_prompt/token/token.rb', line 51

def other_user_names_if_exists
  _user.other_users_count == 0 ?  '' : _user.other_usernames.join(',')
end

#other_users_countObject



64
65
66
# File 'lib/enhanced_prompt/token/token.rb', line 64

def other_users_count
  _user.other_users_count.to_s
end

#time1Object

Delegating to Time resources



103
104
105
# File 'lib/enhanced_prompt/token/token.rb', line 103

def time1
  _time.time1.to_s
end

#uidObject



80
81
82
# File 'lib/enhanced_prompt/token/token.rb', line 80

def uid
  _user.uid.to_s || "No #{__method__}"
end

#usernameObject

Delegating to User resource



35
36
37
# File 'lib/enhanced_prompt/token/token.rb', line 35

def username
  _user.username || ''
end

#usernamesObject



43
44
45
# File 'lib/enhanced_prompt/token/token.rb', line 43

def usernames
  _user.usernames.join(',')
end

#users_countObject



55
56
57
# File 'lib/enhanced_prompt/token/token.rb', line 55

def users_count
  _user.users_count.to_s
end

#users_count_scale1Object

TODO : should be method missing to ***_scale



60
61
62
# File 'lib/enhanced_prompt/token/token.rb', line 60

def users_count_scale1
  vertical_bar_scale(_user.users_count)
end