Class: Ruboty::Karma::Actions::List
- Inherits:
-
Actions::Base
- Object
- Actions::Base
- Ruboty::Karma::Actions::List
- Defined in:
- lib/ruboty/karma/actions/list.rb
Instance Method Summary collapse
Instance Method Details
#args ⇒ Object
20 21 22 |
# File 'lib/ruboty/karma/actions/list.rb', line 20 def args ['args'] ? ['args'].split(/\s+/) : [] end |
#call ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ruboty/karma/actions/list.rb', line 5 def call key = 'karma-list' brain = .robot.brain brain.data[key] ||= [] lists = brain.data[key].map do |user| [user, brain.data["karma-@#{user}"]] end sorted = lists.sort_by { |e| -e[1] } text = sorted.map { |e| e[0] = quiet_name(e[0]) if quiet? e.join(': ') }.join("\n") .reply(text) end |
#quiet? ⇒ Boolean
24 25 26 |
# File 'lib/ruboty/karma/actions/list.rb', line 24 def quiet? args.include?('-q') || args.include?('--quiet') end |
#quiet_name(name) ⇒ Object
28 29 30 |
# File 'lib/ruboty/karma/actions/list.rb', line 28 def quiet_name(name) name.split('').join(' ') end |