Class: Ayadn::Preferences
Instance Attribute Summary collapse
-
#backup ⇒ Object
Returns the value of attribute backup.
-
#blacklist ⇒ Object
Returns the value of attribute blacklist.
-
#channels ⇒ Object
Returns the value of attribute channels.
-
#colors ⇒ Object
Returns the value of attribute colors.
-
#counts ⇒ Object
Returns the value of attribute counts.
-
#formats ⇒ Object
Returns the value of attribute formats.
-
#marker ⇒ Object
Returns the value of attribute marker.
-
#nicerank ⇒ Object
Returns the value of attribute nicerank.
-
#nowplaying ⇒ Object
Returns the value of attribute nowplaying.
-
#scroll ⇒ Object
Returns the value of attribute scroll.
-
#source_hash ⇒ Object
Returns the value of attribute source_hash.
-
#timeline ⇒ Object
Returns the value of attribute timeline.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Preferences
constructor
A new instance of Preferences.
- #to_h ⇒ Object
- #to_table ⇒ Object
Constructor Details
#initialize(hash) ⇒ Preferences
Returns a new instance of Preferences.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# 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 |
Instance Attribute Details
#backup ⇒ Object
Returns the value of attribute backup.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def backup @backup end |
#blacklist ⇒ Object
Returns the value of attribute blacklist.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def blacklist @blacklist end |
#channels ⇒ Object
Returns the value of attribute channels.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def channels @channels end |
#colors ⇒ Object
Returns the value of attribute colors.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def colors @colors end |
#counts ⇒ Object
Returns the value of attribute counts.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def counts @counts end |
#formats ⇒ Object
Returns the value of attribute formats.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def formats @formats end |
#marker ⇒ Object
Returns the value of attribute marker.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def marker @marker end |
#nicerank ⇒ Object
Returns the value of attribute nicerank.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def nicerank @nicerank end |
#nowplaying ⇒ Object
Returns the value of attribute nowplaying.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def @nowplaying end |
#scroll ⇒ Object
Returns the value of attribute scroll.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def scroll @scroll end |
#source_hash ⇒ Object
Returns the value of attribute source_hash.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def source_hash @source_hash end |
#timeline ⇒ Object
Returns the value of attribute timeline.
225 226 227 |
# File 'lib/ayadn/preferences_object.rb', line 225 def timeline @timeline end |
Instance Method Details
#to_h ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# 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 ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# 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 |