Some more methods. When I get unmarked_articles working all
methods from the perl version I need are in. ;)
This commit is contained in:
parent
284c1f4308
commit
507adc9005
1 changed files with 61 additions and 9 deletions
|
|
@ -3,8 +3,6 @@
|
||||||
# $Id$
|
# $Id$
|
||||||
# $Source$
|
# $Source$
|
||||||
#
|
#
|
||||||
#################################
|
|
||||||
#
|
|
||||||
# newsrc.rb
|
# newsrc.rb
|
||||||
# ported from Perl code by Ward Wouts
|
# ported from Perl code by Ward Wouts
|
||||||
#
|
#
|
||||||
|
|
@ -124,7 +122,7 @@ def add_group(name, options)
|
||||||
del_group(name)
|
del_group(name)
|
||||||
end
|
end
|
||||||
group = {"name" => name,
|
group = {"name" => name,
|
||||||
"subscribed" => 1,
|
"subscribed" => true,
|
||||||
"articles" => Set::IntSpan.new }
|
"articles" => Set::IntSpan.new }
|
||||||
|
|
||||||
@newsrc["group"][name] = group
|
@newsrc["group"][name] = group
|
||||||
|
|
@ -324,7 +322,61 @@ def num_groups
|
||||||
return @newsrc["list"].length
|
return @newsrc["list"].length
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def groups
|
||||||
|
list = @newsrc["list"]
|
||||||
|
list = list.collect{|x| x["name"]}
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
|
||||||
|
def sub_groups
|
||||||
|
list = @newsrc["list"]
|
||||||
|
list = list.collect{|x| x["subscribed"] ? x["name"] : nil}
|
||||||
|
list.compact!
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsub_groups
|
||||||
|
list = @newsrc["list"]
|
||||||
|
list = list.collect{|x| x["subscribed"] ? nil : x["name"]}
|
||||||
|
list.compact!
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
|
||||||
|
def marked_articles(name, options = {"where" => ""})
|
||||||
|
unless @newsrc["group"].has_key?(name)
|
||||||
|
add_group(name, options)
|
||||||
|
end
|
||||||
|
return @newsrc["group"][name]["articles"].elements
|
||||||
|
end
|
||||||
|
|
||||||
|
def unmarked_articles(name, from, to, options = {"where" => ""})
|
||||||
|
unless @newsrc["group"].has_key?(name)
|
||||||
|
add_group(name, options)
|
||||||
|
end
|
||||||
|
range = Set::IntSpan.new("#{from}-#{to}")
|
||||||
|
unmarked = range.diff(@newsrc["group"][name]["articles"])
|
||||||
|
return unmarked.elements
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_articles(name, options = {"where" => ""})
|
||||||
|
unless @newsrc["group"].has_key?(name)
|
||||||
|
add_group(name, options)
|
||||||
|
end
|
||||||
|
@newsrc["group"][name]["articles"].run_list
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_articles(name, articles, options = {"where" => ""})
|
||||||
|
Set::IntSpan.valid(articles) or return false
|
||||||
|
set = Set::IntSpan.new(articles)
|
||||||
|
set.finite or return false
|
||||||
|
min = set.min
|
||||||
|
min != nil and min < 0 and return false
|
||||||
|
unless @newsrc["group"].has_key?(name)
|
||||||
|
add_group(name, options)
|
||||||
|
end
|
||||||
|
@newsrc["group"][name]["articles"] = set
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
end # class
|
end # class
|
||||||
|
|
||||||
|
|
@ -364,10 +416,10 @@ end # module
|
||||||
# [x] subscribed
|
# [x] subscribed
|
||||||
# [x] marked
|
# [x] marked
|
||||||
# [x] num_groups
|
# [x] num_groups
|
||||||
# [ ] groups
|
# [x] groups
|
||||||
# [ ] sub_groups
|
# [x] sub_groups
|
||||||
# [ ] unsub_groups
|
# [x] unsub_groups
|
||||||
# [ ] marked_articles
|
# [x] marked_articles
|
||||||
# [ ] unmarked_articles
|
# [ ] unmarked_articles
|
||||||
# [ ] get_articles
|
# [x] get_articles
|
||||||
# [ ] set_articles
|
# [x] set_articles
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue