class WindowTerminal::Window

The main class which handles each individual terminal window.

Attributes

objects[R]
orientation[R]

Public Class Methods

new(orientation,name) click to toggle source

Initializes Window object.

# File lib/accu-window.rb, line 366
def initialize(orientation,name)
        raise "Orientation must be passed!" if not orientation.is_a? Orientation
        @orientation = orientation
        @name = name
        @objects = []
        add_object(WindowTerminal::ColoredText.new(WindowTerminal::Orientation.new,@name,0,:red))
        add_object(WindowTerminal::Line.new(1))
end

Public Instance Methods

[](index) click to toggle source

Allows for array-like indexing of the Window’s objects.

# File lib/accu-window.rb, line 434
def [](index)
        @objects[index]
end
add_object(object) click to toggle source

Adds a single object to the Window’s object list.

# File lib/accu-window.rb, line 383
def add_object(object)
        raise ArgumentError "Argument must be a renderable object." if (not (object.respond_to?(:render_line) or object.respond_to?(:render)))
        @objects << object
end
add_objects(*items) click to toggle source

Adds all passed arguments to the Window’s object list.

# File lib/accu-window.rb, line 390
def add_objects(*items)
        raise ArgumentError "Argument missing" if items.length == 0
        items.each { |item|
                add_object(item)
        }
end
for_objects() { |object| ... } click to toggle source

Yields the passed block with each object.

# File lib/accu-window.rb, line 399
def for_objects()
        @objects.each {|object|
                yield object
        }
end
get_name() click to toggle source

Returns Window’s current name.

# File lib/accu-window.rb, line 418
def get_name()
        @name
end
include_in_render(bool=true) click to toggle source

Includes the Window in the WindowTerminal module screen_render.

# File lib/accu-window.rb, line 424
def include_in_render(bool=true)
        if bool and not WindowTerminal.get_windows().include? self then
                WindowTerminal.add_window self
        elsif not bool and WindowTerminal.get_windows().include? self then
                WindowTerminal.remove_window self
        end
end
set_name(name) click to toggle source

Sets the Window’s current name and changes the displayed name accordingly.

# File lib/accu-window.rb, line 408
def set_name(name)
        raise TypeError "Name must be an string!" if (not name.is_a? String)
        @name = name
        if @objects[0].respond_to? :set_text then
                @objects[0].set_text @name
        end
end
to_s() click to toggle source

Makes the to_s method return something a bit more meaningful.

# File lib/accu-window.rb, line 377
def to_s
        "<Window: @orientation = #{@orientation.to_s}, @name = #{@name} >"
end