labels that will typically be hidden from the user
labels that have special semantics. user will be unable to add/remove these via normal label mechanisms.
# File lib/sup/label.rb, line 63 def << t raise ArgumentError, "expecting a symbol" unless t.is_a? Symbol unless @labels.member?(t) || RESERVED_LABELS.member?(t) @labels[t] = true @new_labels[t] = true @modified = true end end
all labels user-defined and system, ordered nicely and converted to pretty strings. use label_for to recover the original label.
# File lib/sup/label.rb, line 32 def all_labels ## uniq's only necessary here because of certain upgrade issues (RESERVED_LABELS + @labels.keys).uniq end
# File lib/sup/label.rb, line 72 def delete t if @labels.delete(t) @modified = true end end
# File lib/sup/label.rb, line 53 def label_for s l = s.intern l2 = s.downcase.intern if RESERVED_LABELS.include? l2 l2 else l end end
# File lib/sup/label.rb, line 27 def new_label? l; @new_labels.include?(l) end
# File lib/sup/label.rb, line 78 def save return unless @modified File.open(@fn, "w") { |f| f.puts @labels.keys.sort_by { |l| l.to_s } } @new_labels = {} end
reverse the label->string mapping, for convenience!
# File lib/sup/label.rb, line 45 def string_for l if RESERVED_LABELS.include? l l.to_s.capitalize else l.to_s end end
all user-defined labels, ordered nicely and converted to pretty strings. use label_for to recover the original label.
# File lib/sup/label.rb, line 40 def user_defined_labels @labels.keys end
Generated with the Darkfish Rdoc Generator 2.