module RSS::Maker::ITunesBaseModel

Public Instance Methods

def_class_accessor(klass, name, type, *args) click to toggle source
# File lib/rss/maker/itunes.rb, line 8
def def_class_accessor(klass, name, type, *args)
  name = name.gsub(/-/, "_").gsub(/^itunes_/, '')
  full_name = "#{RSS::ITUNES_PREFIX}_#{name}"
  case type
  when nil
    klass.def_other_element(full_name)
  when :yes_other
    def_yes_other_accessor(klass, full_name)
  when :yes_clean_other
    def_yes_clean_other_accessor(klass, full_name)
  when :csv
    def_csv_accessor(klass, full_name)
  when :element, :attribute
    recommended_attribute_name, = *args
    klass_name = "ITunes#{Utils.to_class_name(name)}"
    klass.def_classed_element(full_name, klass_name,
                              recommended_attribute_name)
  when :elements
    plural_name, recommended_attribute_name = args
    plural_name ||= "#{name}s"
    full_plural_name = "#{RSS::ITUNES_PREFIX}_#{plural_name}"
    klass_name = "ITunes#{Utils.to_class_name(name)}"
    plural_klass_name = "ITunes#{Utils.to_class_name(plural_name)}"
    def_elements_class_accessor(klass, name, full_name, full_plural_name,
                                klass_name, plural_klass_name,
                                recommended_attribute_name)
  end
end
def_csv_accessor(klass, full_name) click to toggle source
# File lib/rss/maker/itunes.rb, line 55
def def_csv_accessor(klass, full_name)
  klass.def_csv_element(full_name)
end
def_elements_class_accessor(klass, name, full_name, full_plural_name, klass_name, plural_klass_name, recommended_attribute_name=nil) click to toggle source
# File lib/rss/maker/itunes.rb, line 59
      def def_elements_class_accessor(klass, name, full_name, full_plural_name,
                                      klass_name, plural_klass_name,
                                      recommended_attribute_name=nil)
        if recommended_attribute_name
          klass.def_classed_elements(full_name, recommended_attribute_name,
                                     plural_klass_name, full_plural_name)
        else
          klass.def_classed_element(full_plural_name, plural_klass_name)
        end
        klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
          def new_#{full_name}(text=nil)
            #{full_name} = @#{full_plural_name}.new_#{name}
            #{full_name}.text = text
            if block_given?
              yield #{full_name}
            else
              #{full_name}
            end
          end
        EOC
      end
def_yes_clean_other_accessor(klass, full_name) click to toggle source
# File lib/rss/maker/itunes.rb, line 46
      def def_yes_clean_other_accessor(klass, full_name)
        klass.def_other_element(full_name)
        klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
          def #{full_name}?
            Utils::YesCleanOther.parse(#{full_name})
          end
        EOC
      end
def_yes_other_accessor(klass, full_name) click to toggle source
# File lib/rss/maker/itunes.rb, line 37
      def def_yes_other_accessor(klass, full_name)
        klass.def_other_element(full_name)
        klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
          def #{full_name}?
            Utils::YesOther.parse(@#{full_name})
          end
        EOC
      end