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 rss/maker/base.rb, line 676
def initialize(maker)
  super
  @do_sort = false
  @max_size = -1
end

Public Instance Methods

normalize() click to toggle source
# File rss/maker/base.rb, line 682
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 rss/maker/base.rb, line 691
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