class Omniboard::Group

This class represents a “group” of Projects.

Attributes

brightness[RW]

Global values for group colour brightness and saturation

groups[RW]

All groups in the board

saturation[RW]

Global values for group colour brightness and saturation

colour[RW]

The colour representation of a group

identifier[RW]

The identifier for this group. Can be a string, object, whatever you like.

Public Class Methods

[](identifier) click to toggle source

Find a group by identifier

# File lib/omniboard/group.rb, line 33
def [] identifier
        @groups.find{ |g| g.identifier == identifier } || new(identifier)
end
add(g) click to toggle source

Add a new group to the groups array. Also resets all colour assignments for the group. Note: usually called from initializer.

# File lib/omniboard/group.rb, line 39
def add(g)
        @groups.each(&:reset_colour)
        @groups << g
end
colour()
Alias for: default_colour
default_colour() click to toggle source

If we don't have any groups on our board, this is our default colour for ungrouped projects

# File lib/omniboard/group.rb, line 46
def default_colour
        Omniboard::Colour.new(0).standard
end
Also aliased as: colour
light_colour() click to toggle source

If we don't have any groups on our board, this is our default light colour for ungrouped projects

# File lib/omniboard/group.rb, line 53
def light_colour
        Omniboard::Colour.new(0).light
end
new(identifier) click to toggle source
# File lib/omniboard/group.rb, line 58
def initialize(identifier)
        raise(ArgumentError, "nil identifier not allowed") if identifier.nil?
  @identifier = identifier
  Omniboard::Group.add(self)
end

Public Instance Methods

<=>(o) click to toggle source
# File lib/omniboard/group.rb, line 88
def <=> o
        self.identifier <=> o.identifier
end
assigned_colour() click to toggle source
# File lib/omniboard/group.rb, line 76
def assigned_colour
        Omniboard::Column::colour_for_group(self.identifier)
end
has_assigned_colour?() click to toggle source
# File lib/omniboard/group.rb, line 80
def has_assigned_colour?
        assigned_colour != nil
end
light_colour() click to toggle source
# File lib/omniboard/group.rb, line 68
def light_colour
        colour_obj.light
end
name() click to toggle source

Deprecated methods

# File lib/omniboard/group.rb, line 9
def name
        $stderr.puts "Group#name is deprecated. Use Group#identifier instead."
        @identifier
end
name=(n) click to toggle source
# File lib/omniboard/group.rb, line 14
def name= n
        $stderr.puts "Group#name= is deprecated. Use Group#identifier= instead."
        @identifier = n
end
reset_colour() click to toggle source
# File lib/omniboard/group.rb, line 72
def reset_colour
        @colour_obj = nil
end
to_s() click to toggle source
# File lib/omniboard/group.rb, line 84
def to_s
        @identifier
end

Private Instance Methods

colour_obj() click to toggle source
# File lib/omniboard/group.rb, line 93
def colour_obj
        @colour_obj ||= begin
                my_hue = if has_assigned_colour?
                        assigned_colour
                else
                        unassigned_groups = Omniboard::Group.groups.select{ |g| !g.has_assigned_colour? }
                        360.0 / unassigned_groups.size * unassigned_groups.index(self)
                end
                Omniboard::Colour.new(my_hue)
        end
end