class Alien::AlienTagList
Public Class Methods
new(taglist_string="")
click to toggle source
Calls superclass method
# File lib/alien/alientaglist.rb, line 17 def initialize(taglist_string="") super() string_to_taglist(taglist_string) if taglist_string != "" end
Public Instance Methods
add_tag(t)
click to toggle source
Adds an AlienTag
to the list.
# File lib/alien/alientaglist.rb, line 37 def add_tag(t) self.push(t) return self end
filter(filter)
click to toggle source
A little regular expression scanner. Looks at the list of tags and returns a new taglist containing those tag IDs that match a regular expression filter.
# File lib/alien/alientaglist.rb, line 44 def filter(filter) tl = AlienTagList.new self.each do |ele| if ele.tag =~ filter tl.add_tag(ele) end end return tl end
filter!(filter)
click to toggle source
A self-modifying version of filter_taglist. Excercise caution. Elements in the taglist array that do not match the regular expression are deleted.
# File lib/alien/alientaglist.rb, line 59 def filter!(filter) self.delete_if { |ele| !(ele.tag =~ filter)} return self end
string_to_taglist(taglist_string)
click to toggle source
Takes a taglist string from a reader and appends it to the array.
# File lib/alien/alientaglist.rb, line 24 def string_to_taglist(taglist_string) lines = taglist_string.split("\r\n") lines.each do |line| if line != "(No Tags)" add_tag(AlienTag.new(line)) end end return self end