Class: Command::Freeze
Instance Attribute Summary
Attributes inherited from CommandBase
#stream_io
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from CommandBase
#disable_logging, #display_help!, execute!, #execute!, #force_change_settings_function, help, #hook_call, #load_local_settings, #tagname_to_ids
Constructor Details
#initialize ⇒ Freeze
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/command/freeze.rb', line 17
def initialize
super("<target> [<target2> ...] [options]")
@opt.separator <<-EOS
・指定した小説を凍結し、変更不可属性を付与します。
・凍結することでダウンロード、アップデート及び削除が出来なくなります。
・凍結済みの小説を指定した場合、凍結が解除されます。
Examples:
narou freeze --list
narou freeze n9669bk
narou freeze 0 1 musyoku
Options:
EOS
@opt.on("-l", "--list", "凍結中小説の一覧を表示") {
output_freeze_list
exit 0
}
@opt.on("--on", "現在の状態にかかわらず凍結する") {
@options["on"] = true
}
@opt.on("--off", "現在の状態にかかわらず解除する") {
@options["off"] = true
}
end
|
Class Method Details
.oneline_help ⇒ Object
13
14
15
|
# File 'lib/command/freeze.rb', line 13
def self.oneline_help
"小説の凍結設定を行います"
end
|
Instance Method Details
#execute(argv) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/command/freeze.rb', line 48
def execute(argv)
super
display_help! if argv.empty?
tagname_to_ids(argv)
frozen_list = Inventory.load("freeze")
argv.each do |target|
data = Downloader.get_data_by_target(target)
unless data
puts "#{target} は存在しません"
next
end
id, title = data["id"], data["title"]
flag = !frozen_list.include?(id)
flag = true if @options["on"]
flag = false if @options["off"]
if flag
frozen_list[id] = true
puts "#{title} を凍結しました"
else
frozen_list.delete(id)
puts "#{title} の凍結を解除しました"
next
end
end
frozen_list.save
end
|
#output_freeze_list ⇒ Object
44
45
46
|
# File 'lib/command/freeze.rb', line 44
def output_freeze_list
List.execute!("--filter", "frozen")
end
|