add bunch of methods
remove some debugging stuff
This commit is contained in:
parent
b6f3ced015
commit
284c1f4308
1 changed files with 81 additions and 16 deletions
|
|
@ -166,7 +166,6 @@ def _insert(group, options)
|
|||
when "alpha"
|
||||
alpha(group)
|
||||
when "before"
|
||||
print "metsj\n"
|
||||
before(group, arg)
|
||||
when "after"
|
||||
after(group, arg)
|
||||
|
|
@ -178,7 +177,7 @@ end
|
|||
def alpha (group)
|
||||
name = group["name"]
|
||||
for i in (0...@newsrc["list"].length)
|
||||
print @newsrc["list"][i]["name"],"\n"
|
||||
# print @newsrc["list"][i]["name"],"\n"
|
||||
if ((name <=> @newsrc["list"][i]["name"]) == -1)
|
||||
# splice @$list, $i, 0, $group
|
||||
upper = @newsrc["list"].slice!(i..@newsrc["list"].length)
|
||||
|
|
@ -191,14 +190,14 @@ def alpha (group)
|
|||
end
|
||||
|
||||
def before(group, before)
|
||||
print "before\n"
|
||||
# print "before\n"
|
||||
name = group["name"]
|
||||
|
||||
|
||||
for i in (0...@newsrc["list"].length)
|
||||
print @newsrc["list"][i]["name"],"\n"
|
||||
# print @newsrc["list"][i]["name"],"\n"
|
||||
if (@newsrc["list"][i]["name"] == before.to_s)
|
||||
print @newsrc["list"][i]["name"],"\n"
|
||||
# print @newsrc["list"][i]["name"],"\n"
|
||||
upper = @newsrc["list"].slice!(i..@newsrc["list"].length)
|
||||
@newsrc["list"] += [ group ]
|
||||
@newsrc["list"] += upper
|
||||
|
|
@ -215,7 +214,7 @@ def after(group, after)
|
|||
|
||||
for i in (0...@newsrc["list"].length)
|
||||
if (@newsrc["list"][i]["name"] == after.to_s)
|
||||
print @newsrc["list"][i+1]["name"],"\n"
|
||||
#print @newsrc["list"][i+1]["name"],"\n"
|
||||
upper = @newsrc["list"].slice!((i+1)..@newsrc["list"].length)
|
||||
@newsrc["list"] += [ group ]
|
||||
@newsrc["list"] += upper
|
||||
|
|
@ -261,6 +260,72 @@ def unsubscribe(name, options = {"where" => ""})
|
|||
@newsrc["group"][name]["subscribed"] = false
|
||||
end
|
||||
|
||||
def mark(name, article, options = {"where" => ""})
|
||||
unless @newsrc["group"].has_key?(name)
|
||||
add_group(name, options)
|
||||
end
|
||||
@newsrc["group"][name]["articles"].insert(article)
|
||||
end
|
||||
|
||||
def mark_list(name, list, options = {"where" => ""})
|
||||
unless @newsrc["group"].has_key?(name)
|
||||
add_group(name, options)
|
||||
end
|
||||
articles = @newsrc["group"][name]["articles"].union(list)
|
||||
@newsrc["group"][name]["articles"] = articles
|
||||
end
|
||||
|
||||
def mark_range(name, from, to, options = {"where" => ""})
|
||||
unless @newsrc["group"].has_key?(name)
|
||||
add_group(name, options)
|
||||
end
|
||||
range = Set::IntSpan.new("#{from}-#{to}")
|
||||
articles = @newsrc["group"][name]["articles"].union(range)
|
||||
@newsrc["group"][name]["articles"] = articles
|
||||
end
|
||||
|
||||
def unmark(name, article, options = {"where" => ""})
|
||||
unless @newsrc["group"].has_key?(name)
|
||||
add_group(name, options)
|
||||
end
|
||||
@newsrc["group"][name]["articles"].remove(article)
|
||||
end
|
||||
|
||||
def unmark_list(name, list, options = {"where" => ""})
|
||||
unless @newsrc["group"].has_key?(name)
|
||||
add_group(name, options)
|
||||
end
|
||||
articles = @newsrc["group"][name]["articles"].diff(list)
|
||||
@newsrc["group"][name]["articles"] = articles
|
||||
end
|
||||
|
||||
def unmark_range(name, from, to, options = {"where" => ""})
|
||||
unless @newsrc["group"].has_key?(name)
|
||||
add_group(name, options)
|
||||
end
|
||||
range = Set::IntSpan.new("#{from}-#{to}")
|
||||
articles = @newsrc["group"][name]["articles"].diff(range)
|
||||
@newsrc["group"][name]["articles"] = articles
|
||||
end
|
||||
|
||||
def exists(name)
|
||||
return @newsrc["group"].has_key?(name) ? true : false
|
||||
end
|
||||
|
||||
def subscribed(name)
|
||||
exists(name) and @newsrc["group"][name]["subscribed"]
|
||||
end
|
||||
|
||||
def marked(name, article)
|
||||
exists(name) and @newsrc["group"][name]["articles"].member(article)
|
||||
end
|
||||
|
||||
def num_groups
|
||||
return @newsrc["list"].length
|
||||
end
|
||||
|
||||
|
||||
|
||||
end # class
|
||||
|
||||
end # module
|
||||
|
|
@ -289,16 +354,16 @@ end # module
|
|||
# [x] del_group
|
||||
# [x] subscribe
|
||||
# [x] unsubscribe
|
||||
# [ ] mark
|
||||
# [ ] mark_list
|
||||
# [ ] mark_range
|
||||
# [ ] unmark
|
||||
# [ ] unmark_list
|
||||
# [ ] unmark_range
|
||||
# [ ] exists
|
||||
# [ ] subscribed
|
||||
# [ ] marked
|
||||
# [ ] num_groups
|
||||
# [x] mark
|
||||
# [x] mark_list
|
||||
# [x] mark_range
|
||||
# [x] unmark
|
||||
# [x] unmark_list
|
||||
# [x] unmark_range
|
||||
# [x] exists
|
||||
# [x] subscribed
|
||||
# [x] marked
|
||||
# [x] num_groups
|
||||
# [ ] groups
|
||||
# [ ] sub_groups
|
||||
# [ ] unsub_groups
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue