Sha256: 1ba8d7122920c9d510051931533a1c208e73ec0a7ae88cdebe704e5f12b82ec9

Contents?: true

Size: 920 Bytes

Versions: 6

Compression:

Stored size: 920 Bytes

Contents

module Teamocil
  class Layout

    # This class represents a session within tmux
    class Session
      attr_reader :options, :windows, :name

      # Initialize a new tmux session
      #
      # @param options [Hash] the options, mostly passed by the CLI
      # @param attrs [Hash] the session data from the layout file
      def initialize(options, attrs={}) # {{{
        @name = attrs["name"]
        @windows = attrs["windows"].each_with_index.map { |window, window_index| Window.new(self, window_index, window) }
        @options = options
      end # }}}

      # Generate commands to send to tmux
      #
      # @return [Array]
      def generate_commands # {{{
        commands = []
        commands << "tmux rename-session \"#{@name}\"" unless @name.nil?
        commands << @windows.map(&:generate_commands)
        commands << "tmux select-pane -t 0"
        commands
      end # }}}

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
teamocil-0.3.7 lib/teamocil/layout/session.rb
teamocil-0.3.6 lib/teamocil/layout/session.rb
teamocil-0.3.5 lib/teamocil/layout/session.rb
teamocil-0.3.4 lib/teamocil/layout/session.rb
teamocil-0.3.3 lib/teamocil/layout/session.rb
teamocil-0.3.2 lib/teamocil/layout/session.rb