123456789_123456789_123456789_123456789_123456789_

Class: RSS::Maker::ItemsBase

Relationships & Source Files
Namespace Children
Classes:
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
self, Base
Inherits: RSS::Maker::Base
Defined in: lib/rss/maker/base.rb,
lib/rss/maker/content.rb,
lib/rss/maker/dublincore.rb,
lib/rss/maker/image.rb,
lib/rss/maker/itunes.rb,
lib/rss/maker/slash.rb,
lib/rss/maker/taxonomy.rb,
lib/rss/maker/trackback.rb

Constant Summary

Base - Inherited

NEED_INITIALIZE_VARIABLES, OTHER_ELEMENTS

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(maker) ⇒ ItemsBase

[ GitHub ]

  
# File 'lib/rss/maker/base.rb', line 675

def initialize(maker)
  super
  @do_sort = false
  @max_size = -1
end

Instance Attribute Details

#do_sort (rw)

[ GitHub ]

  
# File 'lib/rss/maker/base.rb', line 673

attr_accessor :do_sort, :max_size

#max_size (rw)

[ GitHub ]

  
# File 'lib/rss/maker/base.rb', line 673

attr_accessor :do_sort, :max_size

Instance Method Details

#normalize

[ GitHub ]

  
# File 'lib/rss/maker/base.rb', line 681

def normalize
  if @max_size >= 0
    sort_if_need[0...@max_size]
  else
    sort_if_need[0..@max_size]
  end
end

#sort_if_need (private)

[ GitHub ]

  
# File 'lib/rss/maker/base.rb', line 690

def sort_if_need
  if @do_sort.respond_to?(:call)
    @items.sort do |x, y|
      @do_sort.call(x, y)
    end
  elsif @do_sort
    @items.sort do |x, y|
      y <=> x
    end
  else
    @items
  end
end