class RSS::Maker::ItemsBase

Attributes

do_sort[RW]
max_size[RW]

Public Class Methods

new(maker) click to toggle source
Calls superclass method RSS::Maker::Base.new
# File lib/rss/maker/base.rb, line 675
def initialize(maker)
  super
  @do_sort = false
  @max_size = -1
end

Public Instance Methods

normalize() click to toggle source
# 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

Private Instance Methods

sort_if_need() click to toggle source
# 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