Module: Slatan::Affiliation::Users
- Included in:
- Slatan::Affiliation
- Defined in:
- lib/slatan/affiliation/users.rb
Class Method Summary collapse
- .get ⇒ Object
-
.get_id(name) ⇒ Object
return id of user name.
-
.get_name(id) ⇒ Object
return name of user id.
-
.is_bot?(ident) ⇒ Boolean
check bot or human.
-
.is_id?(key) ⇒ Boolean
check id or name.
- .set(users) ⇒ Object
Class Method Details
.get ⇒ Object
7 8 9 |
# File 'lib/slatan/affiliation/users.rb', line 7 def get() @users end |
.get_id(name) ⇒ Object
return id of user name
17 18 19 20 21 22 |
# File 'lib/slatan/affiliation/users.rb', line 17 def get_id(name) @users.each do |user| return user[:id] if user[:name] == name end nil end |
.get_name(id) ⇒ Object
return name of user id
26 27 28 29 30 31 |
# File 'lib/slatan/affiliation/users.rb', line 26 def get_name(id) @users.each do |user| return user[:name] if user[:id] == id end nil end |
.is_bot?(ident) ⇒ Boolean
check bot or human
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/slatan/affiliation/users.rb', line 35 def is_bot?(ident) key = if is_id?(ident) then :id else :name end @users.each do |user| if user[key] == ident return user[:is_bot] end end return false end |
.is_id?(key) ⇒ Boolean
check id or name
48 49 50 |
# File 'lib/slatan/affiliation/users.rb', line 48 def is_id?(key) key =~ /^[A-Z0-9]+$/ end |
.set(users) ⇒ Object
11 12 13 |
# File 'lib/slatan/affiliation/users.rb', line 11 def set(users) @users = users end |