Sha256: 7dab85f542e487a02a9663f930b63dd09f24a38034979b1a1bcd7629bd5ad14d

Contents?: true

Size: 1018 Bytes

Versions: 2

Compression:

Stored size: 1018 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={}) # {{{
        raise Teamocil::Error::LayoutError.new("You must specify a `windows` or `session` key for your layout.") unless attrs["windows"]
        @name = attrs["name"] || "teamocil-session"
        @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)
      end # }}}

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
teamocil-0.3.9 lib/teamocil/layout/session.rb
teamocil-0.3.8 lib/teamocil/layout/session.rb