Sha256: 10cc07851c3093bef1dec0974a5d8266f5b8ff44370cef89ad4172fbf7a6a230
Contents?: true
Size: 617 Bytes
Versions: 2
Compression:
Stored size: 617 Bytes
Contents
desc "knows", I18n.t("scripts.knows") respond(/knows/i) do say KnownFormmater.new(know_how).format end class KnownFormmater def initialize(actions) @actions = actions @max_size = @actions.keys.map(&:length).max end def format @actions.inject("```\n") { |_message, command| _message << format_command(command) + "\n" } + "```" end private def name(command_name) pad = @max_size - command_name.length (" " * pad) + command_name end def format_command(command) message = name command.first message << ": #{command.last}" if command.last message end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
boty-0.0.14 | script/knows.rb |
boty-0.0.13 | script/knows.rb |