class Ayadn::Preferences
Attributes
backup[RW]
blacklist[RW]
channels[RW]
colors[RW]
counts[RW]
formats[RW]
marker[RW]
nicerank[RW]
nowplaying[RW]
scroll[RW]
source_hash[RW]
timeline[RW]
Public Class Methods
new(hash)
click to toggle source
# File lib/ayadn/preferences_object.rb, line 227 def initialize hash @source_hash = hash @timeline = PreferencesTimeline.new(hash[:timeline]) @marker = PreferencesMarker.new(hash[:marker]) @counts = PreferencesCounts.new(hash[:counts]) @formats = PreferencesFormats.new(hash[:formats]) @channels = PreferencesChannels.new(hash[:channels]) @colors = PreferencesColors.new(hash[:colors]) @backup = PreferencesBackup.new(hash[:backup]) @scroll = PreferencesScroll.new(hash[:scroll]) @nicerank = PreferencesNicerank.new(hash[:nicerank]) @nowplaying = {} @blacklist = PreferencesBlacklist.new(hash[:blacklist]) end
Public Instance Methods
to_h()
click to toggle source
# File lib/ayadn/preferences_object.rb, line 242 def to_h { timeline: @timeline.to_h, marker: @marker.to_h, counts: @counts.to_h, formats: @formats.to_h, channels: @channels.to_h, colors: @colors.to_h, backup: @backup.to_h, scroll: @scroll.to_h, nicerank: @nicerank.to_h, blacklist: @blacklist.to_h, nowplaying: @nowplaying } end
to_table()
click to toggle source
# File lib/ayadn/preferences_object.rb, line 258 def to_table table = Terminal::Table.new do |t| if @formats.table.borders t.style = { :width => @formats.table.width, border_x: '—', border_i: '+', border_y: '|' } else t.style = { :width => @formats.table.width, border_x: ' ', border_i: ' ', border_y: ' ' } end t.title = "Current Ayadn settings".color(:cyan) t.headings = [ "Category".color(:red), "Parameter".color(:red), "Value(s)".color(:red) ] self.to_h.each_with_index do |(k, v), index| v.each do |x,y| t << :separator if index >= 1 && !@timeline.compact unless y.is_a?(Hash) t << [ k.to_s.color(:cyan), x.to_s.color(:yellow), y.to_s.color(:green) ] else y.each do |c| yk = c[0] tempv = c[1].to_s if tempv.size > 10 yv = "#{tempv[0..7]}..." else yv = tempv end t << [ k.to_s.color(:cyan), x.to_s.color(:yellow), "#{yk} = #{yv}".color(:green) ] end end end end end table end