class Ptf::Group
Public Class Methods
all_groups()
click to toggle source
# File lib/ptf/group.rb, line 90 def all_groups group_arr = [] File.open(Ptf::FileSystem.group_list_file, "r") do |f| f.each_line do |l| name, abbrev = l.gsub(/\s+/, "").split(":") group_arr.push (Ptf::Group.new(name, abbrev)) end end group_arr end
config()
click to toggle source
# File lib/ptf/group.rb, line 27 def config @config = Ptf::Config.get_config if @config.nil? @config end
default_group()
click to toggle source
# File lib/ptf/group.rb, line 104 def default_group default_group = config[:default_group] name, abbrev = default_group.gsub(/\s+/, "").split(":") Ptf::Group.new(name, abbrev) end
from_abbrev(group_abbrev)
click to toggle source
# File lib/ptf/group.rb, line 49 def from_abbrev(group_abbrev) group_file = Ptf::FileSystem.group_list_file File.open(group_file, "r") do |f| f.each_line do |l| name, abbrev = l.gsub(/\s+/, "").split(":") if group_abbrev == abbrev return Group.new(name, abbrev) end end end nil end
from_name(group_name)
click to toggle source
# File lib/ptf/group.rb, line 33 def from_name(group_name) group_file = Ptf::FileSystem.group_list_file File.open(group_file, "r") do |f| f.each_line do |l| name, abbrev = l.gsub(/\s+/, "").split(":") if group_name == name return Group.new(name, abbrev) end end end nil end
get_group(group)
click to toggle source
# File lib/ptf/group.rb, line 65 def get_group(group) if(group.length <= 4 && group == group.upcase) from_abbrev(group) else from_name(group) end end
group_exist?(g)
click to toggle source
# File lib/ptf/group.rb, line 73 def group_exist?(g) group_file = Ptf::FileSystem.group_list_file File.open(group_file, "r") do |f| f.each_line do |l| name, abbrev = l.gsub(/\s+/, "").split(":") if name == g || abbrev == g return true end end end false end
new(name, abbrev)
click to toggle source
# File lib/ptf/group.rb, line 4 def initialize(name, abbrev) @name = name @abbreviation = abbrev end
Public Instance Methods
abbreviation()
click to toggle source
# File lib/ptf/group.rb, line 13 def abbreviation @abbreviation end
is_default?()
click to toggle source
# File lib/ptf/group.rb, line 21 def is_default? Group.default_group.to_s == to_s end
name()
click to toggle source
# File lib/ptf/group.rb, line 9 def name @name end
to_s()
click to toggle source
# File lib/ptf/group.rb, line 17 def to_s "#{name}:#{abbreviation}" end