class Cog::Helpers::SourceInfo

@api developer

Attributes

name[R]
path[RW]

Public Class Methods

new(name) click to toggle source
# File lib/cog/helpers/cascading_set.rb, line 9
def initialize(name)
  @info = []
  @types = []
  @name = name
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/cog/helpers/cascading_set.rb, line 48
def <=>(other)
  (@path || @name) <=> (other.path || other.name)
end
add_source(source, type=nil) click to toggle source
# File lib/cog/helpers/cascading_set.rb, line 15
def add_source(source, type=nil)
  type ||= source
  @info << source
  @types << type
end
override_s(width=nil) click to toggle source
# File lib/cog/helpers/cascading_set.rb, line 38
def override_s(width=nil)
  colorless = "[#{@info.join ' < '}]"
  if width
    x = @info.zip(@types).collect {|source, type| style source, type}
    "[#{x.join ' < '}]" + " " * (width - colorless.length)
  else
    colorless
  end
end
style(text, type) click to toggle source
# File lib/cog/helpers/cascading_set.rb, line 21
def style(text, type)
  case type
  when :built_in
    text.color :cyan
  when :gem
    text.color :blue
  when :user
    text.color :green
  when :plugin
    text.color :yellow
  when :project
    text.color(:white).bright
  else
    text
  end
end
to_s(override_column_width) click to toggle source
# File lib/cog/helpers/cascading_set.rb, line 52
def to_s(override_column_width)
  "#{override_s override_column_width} #{style @path || @name, @types.last}"
end