Class: Command::Freeze
- Inherits:
-
CommandBase
- Object
- CommandBase
- Command::Freeze
- Defined in:
- lib/command/freeze.rb
Instance Method Summary collapse
- #execute(argv) ⇒ Object
-
#initialize ⇒ Freeze
constructor
A new instance of Freeze.
- #oneline_help ⇒ Object
- #output_freeze_list ⇒ Object
Methods inherited from CommandBase
Constructor Details
#initialize ⇒ Freeze
Returns a new instance of Freeze.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/command/freeze.rb', line 16 def initialize super("<target> [<target2> ...]") @opt.separator "\n \u30FB\u6307\u5B9A\u3057\u305F\u5C0F\u8AAC\u3092\u51CD\u7D50\u3057\u3001\u5909\u66F4\u4E0D\u53EF\u5C5E\u6027\u3092\u4ED8\u4E0E\u3057\u307E\u3059\u3002\n \u30FB\u51CD\u7D50\u3059\u308B\u3053\u3068\u3067\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u3001\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8\u53CA\u3073\u524A\u9664\u304C\u51FA\u6765\u306A\u304F\u306A\u308A\u307E\u3059\u3002\n \u30FB\u51CD\u7D50\u6E08\u307F\u306E\u5C0F\u8AAC\u3092\u6307\u5B9A\u3057\u305F\u5834\u5408\u3001\u51CD\u7D50\u304C\u89E3\u9664\u3055\u308C\u307E\u3059\u3002\n\n Example:\nnarou freeze --list\nnarou freeze n9669bk\nnarou freeze 0 1 musyoku\n\n Options:\n EOS\n @opt.on(\"-l\", \"--list\", \"\u51CD\u7D50\u4E2D\u5C0F\u8AAC\u306E\u4E00\u89A7\u3092\u8868\u793A\") {\n output_freeze_list\n exit 0\n }\nend\n" |
Instance Method Details
#execute(argv) ⇒ Object
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 49 def execute(argv) super if argv.empty? puts @opt.help return end frozen_list = LocalSetting.get["freeze"] argv.each do |target| data = Downloader.get_data_by_target(target) unless data puts "#{target} は存在しません" next end id, title = data["id"], data["title"] if frozen_list.include?(id) frozen_list.delete(id) puts "#{title} の凍結を解除しました" next else frozen_list[id] = true puts "#{title} を凍結しました" end end LocalSetting.get.save_settings end |
#oneline_help ⇒ Object
12 13 14 |
# File 'lib/command/freeze.rb', line 12 def oneline_help "小説の凍結設定を行います" end |
#output_freeze_list ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/command/freeze.rb', line 37 def output_freeze_list database = Database.instance puts "凍結中小説一覧" puts " ID | タイトル" LocalSetting.get["freeze"].each do |id, _| data = database.get_data("id", id) if data puts "#{id.to_s.rjust(3)} | #{data["title"]}" end end end |