Sha256: 2957cb1c5442c55a5cd6653859c1974571f7d4cf0c6bb38a852ccfdeab07b8e4

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

module Alf
  module Shell
    class Main
      module ClassMethods

        def relational_operators(sort_by_name = false)
          ops = subcommands.select{|cmd|
             cmd.operator? and cmd.relational? and !cmd.experimental?
          }
          sort_operators(ops, sort_by_name)
        end

        def experimental_operators(sort_by_name = false)
          ops = subcommands.select{|cmd| 
            cmd.operator? and cmd.relational? and cmd.experimental?
          }
          sort_operators(ops, sort_by_name)
        end

        def non_relational_operators(sort_by_name = false)
          ops = subcommands.select{|cmd| 
            cmd.operator? and !cmd.relational?
          }
          sort_operators(ops, sort_by_name)
        end

        def other_non_relational_commands(sort_by_name = false)
          ops = subcommands.select{|cmd| 
            cmd.command?
          }
          sort_operators(ops, sort_by_name)
        end

        private

        def sort_operators(ops, sort_by_name)
          sort_by_name ? ops.sort{|op1,op2| 
            op1.command_name.to_s <=> op2.command_name.to_s
          } : ops
        end

      end
      extend(ClassMethods)
    end # class Main
  end # module Shell
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 lib/alf-shell/alf/shell/command/main/class_methods.rb
alf-0.12.1 lib/alf-shell/alf/shell/command/main/class_methods.rb
alf-0.12.0 lib/alf-shell/alf/shell/command/main/class_methods.rb
alf-0.11.1 lib/alf-shell/alf/shell/command/main/class_methods.rb
alf-0.11.0 lib/alf-shell/alf/shell/command/main/class_methods.rb