lib/ayadn/set.rb in ayadn-1.1.3 vs lib/ayadn/set.rb in ayadn-1.2.0

- old
+ new

@@ -13,10 +13,23 @@ end scroll_config.log(args) scroll_config.save end + desc "nicerank ITEM VALUE", "Set NiceRank filter values" + long_desc Descriptions.set_nicerank + def nicerank *args + nicerank_config = SetNiceRank.new + if args[0] + nicerank_config.send(args[0], args[1]) + else + abort(Status.error_missing_parameters) + end + nicerank_config.log(args) + nicerank_config.save + end + desc "timeline ITEM TRUE/FALSE", "Set ITEM to be activated or not" long_desc Descriptions.set_timeline def timeline(*args) timeline_config = SetTimeline.new if args[0] @@ -139,10 +152,46 @@ def timer(t) Settings.options[:scroll][:timer] = t end end + class SetNiceRank + def initialize + Settings.load_config + Settings.get_token + Settings.init_config + Logs.create_logger + unless Settings.options[:nicerank] + Settings.options[:nicerank] = { + threshold: 2.1, + filter: false, + filter_unranked: false + } + end + unless Settings.options[:colors][:nicerank] + Settings.options[:colors][:nicerank] = :cyan + end + end + def log(args) + x = "New value for '#{args[0]}' in 'NiceRank' => #{args[1]}" + puts "\n#{x}\n".color(:cyan) + Logs.rec.info x + end + def save + Settings.save_config + end + def filter value + Settings.options[:nicerank][:filter] = Validators.boolean(value) + end + def filter_unranked value + Settings.options[:nicerank][:filter_unranked] = Validators.boolean(value) + end + def threshold value + Settings.options[:nicerank][:threshold] = value.to_f + end + end + class SetBackup def initialize Settings.load_config Settings.get_token Settings.init_config @@ -311,9 +360,22 @@ def show_real_name(value) Settings.options[:timeline][:show_real_name] = value end def show_date(value) Settings.options[:timeline][:show_date] = value + end + def show_nicerank value + unless Settings.options[:nicerank] + Settings.options[:nicerank] = { + threshold: 2.1, + filter: false, + filter_unranked: false + } + end + unless Settings.options[:colors][:nicerank] + Settings.options[:colors][:nicerank] = :cyan + end + Settings.options[:timeline][:show_nicerank] = value end end class SetColor def initialize